laziness, impatience, and hubris | |
PerlMonks |
Re: Is there a default array for reg exp memory variables?by tobyink (Canon) |
on Feb 05, 2012 at 22:35 UTC ( [id://951998]=note: print w/replies, xml ) | Need Help?? |
The return value of the "=~" operator (if called in list context) is the array you desire.
You say:
... so clearly you already know the above. Why not just use list context? There is rarely any reason to explicitly avoid it when regexp matching. Please explain what you're trying to actually do, and why performing matches in list context is insufficient. Depending on what you're trying to do, you could consider using named captures, which get stored into the hash %-. If you name the captures appropriately, you could assemble them into an array...
Though obviously that involves modifying the regular expression itself to add the named captures. And it needs a non-archaic version of Perl (at least 5.10).
In Section
Seekers of Perl Wisdom
|
|