Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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?
[Discipulus]: silly one: can i dump all CORE functions?
[Corion]: Hmm - print for keys %CORE:: maybe?
[Corion]: Hm - nope, that only gives me GLOBAL:: as entry. Maybe you can't ...
[Discipulus]: just got GLOBAL::

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-05-23 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?