![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
using smartmatch for range matchingby perltux (Monk) |
on Nov 25, 2023 at 16:03 UTC ( [id://11155820]=perlquestion: print w/replies, xml ) | Need Help?? |
perltux has asked for the wisdom of the Perl Monks concerning the following question:
I use smartmatch for checking whether an integer number is within a certain range, like this: if ( $number~~[1416..1494] ) { do whatever } But since i upgraded to a recent Perl version i'm getting a "Smartmatch is deprecated" warning. Why would such a useful operator be depreciated? Do I really have to replace '~~' with: if ( $number>=1416 and $number<=1494 ) { do whatever } Is there a more elegant solution similar to the smartmatch example? Also is this depreciation of smartmatch definitive or is there a chance that the Perl devs will change their mind and keep it? Perl is great because of these brilliant operators, removing them removes a bit of the uniqueness of Perl.
Back to
Seekers of Perl Wisdom
|
|