in reply to regex capture groups when using DEFINE predicate

A single match (re)sets $1 and $2 (and so on).

If you want to match a regular expression multiple times, you need to do something like:

my @matches = /$re/g;

or

while( $line =~ /$re/g ) { say $1 // $2; }

Replies are listed 'Best First'.
Re^2: regex capture groups when using DEFINE predicate
by unmatched (Sexton) on Apr 03, 2025 at 12:09 UTC

    Oh, that's right I forgot about that!

    Thank you, everything is working fine now with this adjustment. Cheers.