Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 imbibing at the Monastery: (5)
As of 2014-12-21 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (108 votes), past polls