http://www.perlmonks.org?node_id=567974


in reply to Re: What I Most Recently Learned in Perl, But Should Have Already Known
in thread What I Most Recently Learned in Perl, But Should Have Already Known

Continuing the if-else statements problem, the idiom I like most is:

my $function = 'a'; my %functions = ( 'a' => sub { ... }, 'b' => sub { ... }, ); $functions{$function}->();

It's amazing how this replace an entire switch or if-else statements.

Igor 'izut' Sutton
your code, your rules.