Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Think about Loose Coupling
 
PerlMonks  

Re: Re: Parameters, subs and the shift function

by edan (Curate)
on Aug 19, 2003 at 10:22 UTC ( [id://284906]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Parameters, subs and the shift function
in thread Parameters, subs and the shift function

Update: This node is in response to davorg's post, which he has subsequently updated by removing the offending material, so this response as well as the response of Foggy Bottoms becomes garbage. I think in the future, davorg, you should strike out or otherwise update your node, instead of just deleting material that people have already related to.

so that when you use the shift tool you don't end up with @array1 being "mary","had","a","little","lamb","!","London","Bridge","is"); and @array2 nothing...

With your code, that's exactly what would happen.

No, you're wrong. shift returns the first value in the flattened argument list each time it is called, and removes it, so @array1 will be ("mary"), and @array2 will be ("had"). If the code would have been written like this:

my ($number, @array1, @array2) = @_;

... then you'd be right.

--
3dan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://284906]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.