Hi Shawn,

I hope it's OK that I CC the list on it.

On Monday 12 Apr 2010 15:37:02 Shawn H Corey wrote:
> Shlomi Fish wrote:
> > {{{
> > my $hash = shift;
> > }}}
> 
> Always put the array after a shift:
> 
>    my $hash = shift @_;
> 

Well, you don't need to in this case as <<shift;>> inside a subroutine already 
shifts out of @_ by default. We've already been there:

http://www.nntp.perl.org/group/perl.beginners/2010/03/msg111825.html

Maybe you haven't read my response or Bob McConnell's response to mine.

> > You should always say <<"STOPHTML" <<'STOPHTML' <<`STOPHTML` etc. with
> > explicit quotes depending on what you say. Otherwise, you may not be sure
> > that it's doing the right thing (nor will your readers). See Perl Best
> > Practices for more information.
> 
> Why does putting the quotes in make this "best" practice but always
> putting the array name after a shift not?

Because people often don't know for sure what is the right way, and confuse 
it. On the other hand, people don't normally think that "shift;" will shift 
out of @ARGV when inside a subroutine (because they can tell they are inside a 
subroutine, and because normally you should extract arguments out of @_ at the 
beginning.), or think that it will shift out of the invalid @_ when in global 
scope. It's not very possible to confuse the two, and furthermore complex 
cases like using either of them repetitively in a loop should be avoided in 
favour of using Getopt::Long, named arguments, etc.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

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/


Reply via email to