http://qs321.pair.com?node_id=1054192


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.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.