in reply to Re^2: global regex returning a list of arrays?
in thread global regex returning a list of arrays?
BTW: couldn't find an array holding the values of $1,$2,... in the perldocs !?!
Probably not much help in this particular case (and you still need to loop to capture), but 5.10 offers the %+ and %- predefined hashes for named captures (see perlvar) in place of an array of all capture groups:
>perl -wMstrict -le "my $s = '12ab34cd56ef78'; my @pairs; push @pairs, [ $+{A}, $+{B} ] while $s =~ m{ (?<A>[[:alpha:]]) (?<B>[[:alpha:]]) }xmsg; use Data::Dumper; print Dumper \@pairs; " $VAR1 = [ [ 'a', 'b' ], [ 'c', 'd' ], [ 'e', 'f' ] ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: global regex returning a list of arrays?
by LanX (Saint) on Feb 20, 2010 at 21:28 UTC |