Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: I am confused by a "Learning Perl" sample showing "unshift"

by talexb (Canon)
on Jan 23, 2021 at 15:16 UTC ( #11127337=note: print w/replies, xml ) Need Help??


in reply to I am confused by a "Learning Perl" sample showing "unshift"

I'm just going to link to this node of mine that I think explains how all of these operators work.

In reality, I never use shift or unshift; I use push lots, and pop only occasionally. The only time I see shift used is at the top of a sub (my $foo = shift), and that's a code pattern that I dislike. I much prefer the pattern

my ( $this, $that, $other ) = @_;
over three successive shift statements. Just about any time you're doing a cut and paste in your code, alarm bells should be going off that ask -- "Is this really the correct thing to be doing?"

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-09-24 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?