in reply to replace conditionals with polymorphism
Personally, I'd just use a dispatch table, at least as long as your conditions A, B, C and D conveniently map to strings, like plain strings or regular expressions do:
my $foo = get_user_input(); my %actions = ( A => sub {a;}, B => sub {b;}, C => sub {c; b;}, D => sub {d;}, ); if (not exists $actions{$foo}) { $foo = 'A'; }; $actions{$foo}->();
|
|---|