Syntactic Confectionery Delight | |
PerlMonks |
Returning _which_ pattern matched...?by Boudicca (Initiate) |
on Aug 03, 2001 at 08:00 UTC ( [id://101878]=perlquestion: print w/replies, xml ) | Need Help?? |
Boudicca has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, noble monks -- I have a quandry: Say you have a string and a few patterns to try matching, something like this (it's dinky, please forgive):
$string = "clintonesque"; What I want to know is _which_ of those three things ($m1, $m2, $m3) it matched first. Can it be done, or am I delusional? I should note that I'd like to put all of the match patterns into one monster regexp, instead of if/else-ing my way through a series of them. (Honestly, I don't know why; this was a suggestion from a more experienced engineer, in the interest of conserving computer juice with some pre-compiling.) The FAQs/resources don't offer any aid, and other Perl wizards say it can't be done. I would be intensely grateful for any ideas... Thanks!
Back to
Seekers of Perl Wisdom
|
|