in reply to Subroutines: @_ and shift
Are you sure you are quoting Learning Perl fairly? I suspect that what you saw was
which, likemy ($blah) = @_;
assigns the first element of @_ to $blah, although the form using shift has the additional effect of removing this first element from @_. Or maybe you sawmy $blah = shift;
which assigns all of @_ to the array @blah.my @blah = @_;
In contrast, what you quoted,
just assigns to $blah the size of @_.my $blah = @_;
BTW, golfers are partial to pop:
or perhaps I should saymy $blah = pop;
which is equivalent to shift when @_ has length 1 (or 0), butsavesem2strokes.$b=pop;
the lowliest monk
|
|---|