Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
global regex returning a list of arrays?by LanX (Saint) |
on Feb 20, 2010 at 14:30 UTC ( [id://824385]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi I was wondering about the best way to get the structure of a list of matches. i.e. /($re1)($re2)/g produces a list of paired matches but when processing with map or grep you need a counter to know which item you got grep { } $str=~/($re1)($re2)/g Thats not very scalable... Does anybody know a nifty way to get a list of arrays returned, like in do {my @a; push @a, [$1,$2] while $str=~/($re1)($re2)/g; @a } ??? some code examples:
Cheers Rolf
Back to
Seekers of Perl Wisdom
|
|