![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Find out which subpattern matched in regexby Dallaylaen (Chaplain) |
on Jun 14, 2013 at 12:19 UTC ( [id://1038952]=perlquestion: print w/replies, xml ) | Need Help?? |
Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question: Suppose I have a set of regural expression, and I want to match a string against them all together and do something depending on which of those expressions did match. If those are just words, life's easy: put them all in parentheses and see what's in $1 after match. I think I can use named captures:
The above code sample works, but maybe there are simpler variants and/or variants compatible with older perls?
Back to
Seekers of Perl Wisdom
|
|