|Keep It Simple, Stupid|
Smartmatch alternativesby cavac (Deacon)
|on Dec 17, 2013 at 12:52 UTC||Need Help??|
cavac has asked for the
wisdom of the Perl Monks concerning the following question:
Since 5.18, perl is throwing warnings about smartmatch ans well as given/when.
Mostly i use the ~~ smartmatch operator to test if a scalar exists within an array. Can use the exists() function either, because it's use on arrays is deprecated as well.
Is there a proper, future-proof alternative that does not require me to sprinkle foreach test loops all over the place?
What alternatives are there to given/when?
Personal remark: The perl developers want to axe smartmatch because it is 'too confusing', apparently. I agree that there are some edge cases, but it looks mostly OK to me. What i really, really find confusing, misleading, ugly, hard to follow when reading code and downright stupid is the implicit use of $_. Now THAT is a 'feature' that should have died instead - a long, horribly painful death including hollywood-like special effects would be preferred if that can be arranged.
"I know what i'm doing! Look, what could possibly go wrong? All i have to pull this lever like so, and then press this button here like ArghhhhhaaAaAAAaaagraaaAAaa!!!"