Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: 'switch' and 'smartmatch' features deprecated in 5.38

by ibm1620 (Friar)
on Jun 28, 2023 at 01:45 UTC ( [id://11153163] : note . print w/replies, xml ) Need Help??


in reply to Re: 'switch' and 'smartmatch' features deprecated in 5.38
in thread 'switch' and 'smartmatch' features deprecated in 5.38

I guess for sheer conciseness this would work:
for ( keys %opts ) { /h/ ? HELP_MESSAGE() : /v/ ? ++$verbose : /f/ ? ++$force : /t/ ? $table = $opts{$_} : die "*** BUG: no handler for -$_.\n"; }

Replies are listed 'Best First'.
Re^3: 'switch' and 'smartmatch' features deprecated in 5.38
by swl (Parson) on Jun 28, 2023 at 01:53 UTC

    Although one should first check the keys are all single letter for this case, otherwise one will get matches for words like haft, vatful and thrive.

      %opts was populated by Getopt::Std, so the keys are guaranteed to be one character.