Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 2014-08-28 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls