Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Avoiding if/else knots

by izut (Chaplain)
on Aug 18, 2006 at 12:28 UTC ( [id://568121]=note: print w/replies, xml ) Need Help??


in reply to Avoiding if/else knots

I think that is a common practice in Perl. I always write code like this:

my %functions = ( 'this' => sub { ... }, 'that' => \&do_something, ); my %attrs = (...); my $key = 'this'; $functions{$this}->(\%attrs);

Hope this helps.

Igor 'izut' Sutton
your code, your rules.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://568121]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-16 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found