http://www.perlmonks.org?node_id=11127646


in reply to Comparing a value to a list of numbers

well, for completeness:

There is smartmatch ~~ (sometimes) acting like an in operator

DB<24> $x=5 DB<25> p $x ~~ [1,2,5,6,9,10,41..56] 1 DB<26> $x=0 DB<27> p $x ~~ [1,2,5,6,9,10,41..56] DB<28>

but

WARNING: Smartmatch is experimental

so you'd need to deactivate the warning and hope it'll never vanish (at your risk)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Comparing a value to a list of numbers (in via smartmatch)
by Marshall (Canon) on Jan 30, 2021 at 02:27 UTC
    I personally would not use the smartmatch operator for anything.
    I did some experimenting with this experimental operator and found out that it is "too smart for me!". I could not accurately predict what this thing would actually do!
      I agree, but there is a real need for an "in"-operator like in other languages.

      I hope this aspect will survive somehow and I listed it for completeness with full warning.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery