Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How do I reference repeated capture groups?

by Fletch (Bishop)
on Aug 12, 2022 at 14:43 UTC ( [id://11146122]=note: print w/replies, xml ) Need Help??


in reply to How do I reference repeated capture groups?

Is there something wrong with the (obvious?) just surround both groups with another outer set of parens (which then shifts the numerics down by one)? Should work with a named mark as well.

my $re = qr/(?<whole_enchilada> (?<Letter>\w+) (?<Digit>\s*\d+\s*)* )/ +x;

Edit: NVM, misread what was being asked. You could wrap the second set of parens outside the quantifier I believe but that's not going to preserve the separate matches. ENOCAFFEINE . . .

Edit 2: Playing with %- and friends I'm not finding anything obvious. The other suggestion about using minor ebil like embedded code pushing to an array sounds like the most promising.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-19 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found