Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by Roger (Parson)
on Mar 01, 2004 at 13:26 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found