Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Avoiding if/else knots

by ikegami (Patriarch)
on Aug 18, 2006 at 18:20 UTC ( [id://568234]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Avoiding if/else knots
in thread Avoiding if/else knots

When dealing strictly with small positive integers like in your example, an array might be better than a hash.

sub action_1_to_999 { print "1 to 999\n"; } my @dispatch = ( sub { print "Zero\n" }, map { \&action_1_to_999 } ( 1 .. 999 ), sub { print "1e3\n" }, ); $dispatch[0]->(); $dispatch[23]->();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found