in reply to Conditional style (if, &&) query
Consider this nasty block:
To this, much nicer block:my $arg = shift; if ($arg eq 'one') { do_stuff() } elsif ($arg eq 'two') { do_other_stuff() } elsif ($arg eq 'three') { do_even_more_other_stuff() } else { do_yet_even_more_other_stuff() }
Who even needs if? :D (um, sarcasm)my $arg = shift || 'DEFAULT'; my %lookup = ( one => \&do_stuff, two => \&do_other_stuff, three => \&do_even_more_other_stuff, DEFAULT => \&do_yet_even_more_other_stuff, ); $lookup{$arg}->();
jeffa
|
|---|