Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: shift vs @_

by jasonk (Parson)
on Oct 02, 2006 at 19:41 UTC ( #575934=note: print w/ replies, xml ) Need Help??


in reply to Re: shift vs @_
in thread shift vs @_

Now if you just mean why not always use the my( $a, $b, $c ) = @_; form vice shift: there's times when you want to pull off some items and then do something list-y with the remaining contents of @_. Best example off the top of my head would be something that builds a hash from key/value pairs like:

Another good example is subclassing...

sub do_something { my $self = shift; $self->SUPER::do_something( @_ ); # do some more stuff }

We're not surrounded, we're in a target-rich environment!


Comment on Re^2: shift vs @_
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-07-14 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls