in reply to Smartmatch alternatives
I needed just such a replacement when I went through my own distributions replacing ~~, so I wrote match::simple. It's a less confusing smart match operator. Syntax:
use match::simple; foobar() if $needle |M| $haystack;
The |M| bit is a pseudo-operator (a trick accomplished using somewhat crazy overloading of the bitwise-or operator). If you'd prefer to use it without all the crazy, match::simple also exports a match function:
use match::simple 'match'; foobar() if match $needle, $haystack;
match::simple has simpler, easier to remember rules than ~~, but it also comes bundled with match::smart which uses the same rules as ~~.
For given and when you could try Switcheroo or Switch::Plain, or dispatch tables, or long lists of elsif blocks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Smartmatch alternatives
by cavac (Prior) on Dec 17, 2013 at 15:25 UTC | |
by tobyink (Canon) on Dec 17, 2013 at 16:25 UTC |