in reply to Escape Quote-Like Operators
What's your actual use case? You can save a bunch of characters by not branching (in your nonsensical example):
Update: Or, if you pay 3 more (still saving 2 from your 'ideal') you can get identical algorithmic behavior:$_ = '12'; s/\d/n/g;s/n+/m/;
LTS FTW$_ = '12'; s/\d\d+/m/||s/\d/n/;
Thanks to Anonymous Monk, realized my brain misread the comparator. However, the real use case is still relevant. As penance, optimization of the nonsensical example:
$_ = '12'; s/\d+/$&>10?'m':n/e;
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Escape Quote-Like Operators
by Anonymous Monk on Sep 11, 2013 at 20:24 UTC | |
by kennethk (Abbot) on Sep 11, 2013 at 21:08 UTC |
In Section
Seekers of Perl Wisdom