Regexp capture group list

Jasper jaspermccrea at gmail.com
Tue Nov 10 13:59:24 GMT 2009


2009/11/10 Philip Newton <philip.newton at gmail.com>:
> On Tue, Nov 10, 2009 at 14:11, Paul LeoNerd Evans
> <leonerd at leonerd.org.uk> wrote:
>> After some headscratching I decided instead to have parse() return a
>> list of the capture groups. I so far haven't found a neater expression
>> than
>>
>>
>>  sub parse
>>  {
>>    my ( $text, $re ) = @_;
>>    $_[0] =~ s/^$re// or die "Expected $re in $text...\n";
>>
>>    return map { substr $text, $-[$_], $+[$_]-$-[$_] } 1 .. $#+
>>  }

return map $$_, 1..$#-

too hideous? (I would think it was fine...)


-- 
Jasper



More information about the london.pm mailing list