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

Re: Subroutines: @_ and shift

by mlh2003 (Scribe)
on May 14, 2005 at 13:32 UTC ( #457059=note: print w/replies, xml ) Need Help??


in reply to Subroutines: @_ and shift

The other difference is that:
my (@blah) = @_;
basically copies all parameters passed to the array from @_ to @blah. It leaves @_ intact (for other processing if required).

Whereas:
my $blah = shift;
will REMOVE the first element of the parameter array @_ and place it in the $blah scalar. 'shift'ing will shorten the @_ array. This, as gaal mentioned, modifies @_.
_______
Code is untested unless explicitly stated
mlh2003

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2021-10-22 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?