Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Perl Idioms Explained - my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /}

by Roger (Parson)
on Mar 01, 2004 at 13:26 UTC ( #332886=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /};
    
  2. or download this
    shift(@_)
      # get an element from the parameter list
    ...
    my ($foo, $bar) = @{ shift(@_) }{ qw/ -foo -bar / };
      # assign the two element list retrieved into $foo and $bar
    
  3. or download this
    foobar({ -foo => 'FOO', -bar => 'BAR' });
    
    ...
        my ($foo, $bar) = @{shift(@_)}{qw/ -foo -bar /};
        print "\$foo => $foo, \$bar => $bar\n";
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-03 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls