Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: shifting arguments

by MZSanford (Curate)
on Aug 22, 2001 at 20:04 UTC ( [id://107009]=note: print w/replies, xml ) Need Help??


in reply to shifting arguments

Stirctly speaking, shift() can be used on any array to remove the top (0th) element and return it. But, shift() defaults to @_ if no array is supplied. Since shift is removeing and returning only the first (0th) element, assigning it's return to and array does not work. But, since Perl always tries it's hardest, it take the one value from the right (the return from shift) and assigns it to the first element on the left. Then, when there is no second value, it simply assigns undef to the folloing vars. Thats the simple version, without getting into stacks and such
can't sleep clowns will eat me
-- MZSanford

Replies are listed 'Best First'.
Re: Re: shifting arguments
by Ea (Chaplain) on Aug 23, 2001 at 13:15 UTC
    Well and good, but I swear blind (maybe just myopic) that, when called in a list context, shift would depopulate @_ faster than Jimmy-Crack-Corn. Perhaps it only populates @list that way and not ($a, $b, $c).

    I'm off to do some experiments
    <sound of rustling pages and rummaging through dusty tomes>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-23 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found