Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by talexb (Chancellor)
on Jan 23, 2021 at 15:16 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-18 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found