> I have read a lot about NOT using the switch statement of yore,

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

Short version

workarounds

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.