Switch-Right
view release on metacpan or search on metacpan
lib/Switch/Right.pm view on Meta::CPAN
C<'given'>/C<'when'> and smartmatching are going away.
And for some very good reasons! Smartmatching is just too damn clever
for most people (including its inventor!) to be able to easily remember
L<all the rules|https://perldoc.perl.org/5.40.0/perlop#Smartmatch-Operator>
about what matched what.
And the weird extra-special special-case behaviour of some (but not all) boolean expressions
in a C<when> only makes things even worse.
Hindsight is supposedly 20/20 and E<mdash> in hindsight E<mdash> smartmatching
should have been a lot simpler, a lot more explicit, and a lot easier to remember/predict.
That's what this module attempts to accomplish: to redesign the smartmatching
and the C<given>/C<when> mechanisms so that they're easier to use and easier
to understand.
It implements a version of smartmatching with only six rules to remember,
eliminates all of that magical auto-distributivity of C<when> expressions,
and provides clearer and more explicit ways to specify all those complicated
and hard-to-remember special-case I<"match any of..."> and I<"match all of...">
( run in 2.099 seconds using v1.01-cache-2.11-cpan-71847e10f99 )