Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Why doesn't Perl provide %_ as the hash equivalent of @_ in subs?

by smls (Friar)
on Sep 26, 2013 at 09:47 UTC ( #1055803=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub dostuff {
      my %arg = @_;
    ...
    }
    
    dostuff( foo => 'FOO', bar => 1 );
    
  2. or download this
    sub_with_callbacks (
      red    => sub { my %arg = @_; .. $arg{foo} .. },
    ...
      blue   => sub { my %arg = @_; .. $arg{foo} .. },
      yellow => sub { my %arg = @_; .. $arg{foo} .. }
    );
    
  3. or download this
    sub_with_callbacks (
      red    => sub { .. $_{foo} .. },
    ...
      blue   => sub { .. $_{foo} .. },
      yellow => sub { .. $_{foo} .. }
    );
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-08-22 13:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (157 votes), past polls