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
In reply to Re: Use of SWITCH vs IF ELSE in speed and readability
by Zaxo
in thread Use of SWITCH vs IF ELSE in speed and readability
by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |