Seems like you are referring to use Switch which is a source filter and strongly discouraged.
> but saw some comments on using when instead.
This is most likely referring to given/when activated with use feature "switch" or use 5.10
see https://perldoc.perl.org/perlsyn#Switch-Statements
but also the limitations listed in
https://perldoc.perl.org/perlsyn#Experimental-Details-on-given-and-when
Most ppl I know - me included - prefer simpler workarounds depending on the use case like:
a) For multiple tests till it fits
b) For faster direct lookup of the case (i.e. the comparison operation is always equality eq or == )
As you can see is switch trying to be overly clever and to cover a multitude of cases and optimizations.
It would really help to know your explicit use case.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) I originally wrote "explicit break", but as Athanasius msged me are "break statement only for given/when constructs". Thanks Athanasius++ :)
In reply to Re: Modern exposition of "case" or Switch in perl 5.34?
by LanX
in thread Modern exposition of "case" or Switch in perl 5.34?
by symgryph
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |