Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: shift vs @_

by shmem (Chancellor)
on Oct 02, 2006 at 19:33 UTC ( [id://575932]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        # 1. non-destructive
        my $var = $_[0];                      # first element of @_
    ...
        # 2. destructive
        my $var = shift;                      # first element gets removed
    + from @_
        my ($foo, $bar) = map { shift } 1,2;  # two elements get removed f
    +rom @_
    
  2. or download this
    sub foo {
        my $foo = $_[0];
        my $quux = baz(@_)
        return $foo ^= $quux;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found