in reply to Use of SWITCH vs IF ELSE in speed and readability
Another approach is to use a dispatch table - a hash of code references,
my $dtbl = { 1 => sub { $abc = 1 }, 2 => sub { $def = 1 }, 3 => sub { $xyz = 1 }, }; exists $dtbl->{$x} ? $dtbl->{$x}() : $nothing = 1;
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Use of SWITCH vs IF ELSE in speed and readability
by halley (Prior) on Sep 01, 2003 at 03:37 UTC |