I believe that the 'modern way' is to fall back to either a chain of
elsif for simple choices such as this:
while ( my ( $k, $v ) = each %opts ) {
for ($k) {
if (/h/) { ...; }
elsif (/v/) { ++$verbose; }
elsif (/i/) { $infile = $v; }
else { die "*** BUG: no handler for -$k.\n"; }
}
}
or a 'dispatch table' for more complex switches.
while ( my ( $k, $v ) = each %opts ) {
state %dispatch = (
h => sub{...;},
v => sub{ ++$verbose;},
i => sub{ $infile = $v; },
);
die "*** BUG: no handler for -$k.\n" if !exists $dispatch{$k};
&{$dispatch{$k}};
}