Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re (tilly) 1: use slack;

by tilly (Archbishop)
on Dec 19, 2000 at 23:38 UTC ( [id://47452]=note: print w/replies, xml ) Need Help??


in reply to use slack;

You do have code for these cases? So in addition to your logic above you have:
sub this { return "this"; # Whatever } sub that { return "that"; # Being simple here } # etc
Combine the two:
my %action = ( this => sub {return "this"}, that => sub {return "that"}, # etc ); # Then later: if (exists $action{$in}) { $action{in}->(); }
In fact if you have a lot of cases you can probably find room to factor:
sub ret_simple_returner { my $arg = shift; return ($arg, sub {$arg}); } my %action = map ret_simple_returner($_), qw(this that);
The point being that every time you eliminate the need to keep two pieces of code in sync you eliminate another possible source of bugs...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found