On Thursday 25 Mar 2010 18:52:09 Shawn H Corey wrote:
> On Thu, 25 Mar 2010 17:13:53 +0200
>
> Shlomi Fish <[email protected]> wrote:
> > sub display_page
> > {
> >
> > my $a_server = shift;
> > my $a_pass = shift;
> > .
> > .
> > .
> >
> > }
> > }}}
> >
> > (shift is short for << shift(@_) >> )
>
> If you're going to use shift, name the array.
>
> my $var;
>
> sub foo {
> $var = shift; # shifts @_
> }
> {
> $var = shift; # shifts @ARGV
> }
>
> Without the array, it's easy to forget what is being shifted.
> Remember, things that behave differently should look different.
Well, this is a bike shed argument. I find using "shift;" instead of
"shift(@_);" when inside subroutines to be faster to write, more concise and
more idiomatic. shift has this magic for a reason. I'm unlikely to use shift
the other way when outside or inside subroutines. (And if I do, my automated
tests will catch this.)
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
"Humanity" - Parody of Modern Life - http://shlom.in/humanity
Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/