in reply to Re^3: Capturing regex from map
in thread Capturing regex from map
I think you're wrong about clearer.
But bedsides that, it does not do (and cannot me made to do), the same thing:
@a = map{ m[(..)(.)]g } 'the quick brown fox', 'jumps over the lazy do +g';; print @a;; th e q u ic k b r ow n f o ju m ps ov e r t he la z y d @a = map{ m[(..)(.)]g; $1 || () } 'the quick brown fox', 'jumps over t +he lazy dog';; print @a;; th ju
Perl is context sensitive. If you do not understand what that is, or try ignore it, you will never make best use of Perl.
On the other hand, if you take a few hours or days to understand context sensitivity, the OPs code is clear, concise, and very readable.
And very powerful. It requires many extra, contorted (and ultimately redundant) lines of code to achieve the same thing without using the effects of list context. It is a tool, that once you've realised its powerful simplicity, you will not want to do without.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Capturing regex from map
by LanX (Saint) on Sep 15, 2013 at 18:57 UTC | |
by BrowserUk (Patriarch) on Sep 15, 2013 at 21:13 UTC | |
by Anonymous Monk on Sep 16, 2013 at 01:17 UTC | |
by BrowserUk (Patriarch) on Sep 16, 2013 at 01:38 UTC | |
by Anonymous Monk on Sep 16, 2013 at 06:06 UTC |