Oops, caught my own mistake...

In a message dated Fri, 12 Apr 2002, Trey Harris writes:
> In a message dated Fri, 12 Apr 2002, Luke Palmer writes:
> > sub printRec {
> >   my $p = chomp(shift // $_);
> >   print ":$_:\n"
> > }

[Should be equivalent to]

>   sub printRec {
>     my $p = chomp(shift // shift);
>     print ":$p:\n";
>   }

Actually, it should be equivalent to

  sub printRec {
    my $p = chomp(shift // @_[0]);
    print ":$p:\n";
  }

No shifting is happening just by referring to $_.

Because $_ is always the topic, which is always the first parameter to a
block, which in subroutines is @_[0], right?  So in a sub, $_ == @_[0].
The only question I have is if you modify @_ with a shift, does $_
continue to point at the old @_[0], or does it now point at the new @_[0],
the original @_[1]?

Trey

Reply via email to