Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Parameters, subs and the shift function

by davorg (Chancellor)
on Aug 19, 2003 at 10:13 UTC ( [id://284900]=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 Parameters, subs and the shift function

How does the sub manage to figure out what's the size of @a and @b

It doesn't

Update: Yes, as 3dan points out below, there was some incorrect nonsense in this node for about 30 seconds after I posted it. When I realised my error I removed it immediately. Sorry for any confusion caused.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re: Parameters, subs and the shift function

Replies are listed 'Best First'.
Re: Re: Parameters, subs and the shift function
by Foggy Bottoms (Monk) on Aug 19, 2003 at 10:17 UTC
    That's not what I understand from what 3dan said, so I'm a bit puzzled. Anyway, I updated my code and the arrays work fine now (cuz I actually had the problem but since I hadn't bothered printing out @array1 and @array2 I hadn't noticed the error, not until I felt the urge to satisfy my curiosity and ask the question here...)
    Thanks
Re: Re: Parameters, subs and the shift function
by edan (Curate) on Aug 19, 2003 at 10:22 UTC

    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://284900]
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.