in reply to Returning regexp pattern that was used to match
First off a few comments not related to your question:
If your using any other regexs in your program avoid $& wrap your test in a () instead. $& will cause all regexs to run slower through your whole program.
Don't use map in a void context, it throws away the output. Try for (keys(${$args})) {$string .= $_ . "|"} I would usualy consider join even better but it would not work for my idea bellow.
As for you question you could try (?{ CODE }) to set a variable to the matched code, maybe something like this:
If your using any other regexs in your program avoid $& wrap your test in a () instead. $& will cause all regexs to run slower through your whole program.
Don't use map in a void context, it throws away the output. Try for (keys(${$args})) {$string .= $_ . "|"} I would usualy consider join even better but it would not work for my idea bellow.
As for you question you could try (?{ CODE }) to set a variable to the matched code, maybe something like this:
our $matched_key; #global to hold the key that matched, off the top of + my head I don't think a 'my' variable would work. for (keys($$args)) { $string .= "$_(?{$matched_key = $_})|"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Don't cargo cult "advice"
by Abigail-II (Bishop) on May 03, 2004 at 15:04 UTC | |
by Ven'Tatsu (Deacon) on May 03, 2004 at 15:38 UTC | |
by Abigail-II (Bishop) on May 03, 2004 at 15:40 UTC | |
by Ven'Tatsu (Deacon) on May 03, 2004 at 16:11 UTC | |
by Abigail-II (Bishop) on May 03, 2004 at 16:19 UTC | |
Re: Re: Returning regexp pattern that was used to match
by crabbdean (Pilgrim) on May 03, 2004 at 15:18 UTC | |
by Ven'Tatsu (Deacon) on May 03, 2004 at 15:53 UTC |
In Section
Seekers of Perl Wisdom