in reply to Finding out which of a list of patterns matched
One way I could do this would be to use a pattern similar to the above and then take the text that matched and check it against all of my patterns in order until I find the one it matched
That sounds like exactly the same problem I had once, which led me to write the "tracked" pattern mode of Regexp::Assemble. Take a look at that, I think it will do just what you want.
In essence: you take all your patterns, assemble them into one pattern with tracking enabled, and then look for matches with that. When you get a match (using that one pattern), you can then retrieve the original pattern that would have matched in its place.
There are a couple of scripts in the eg/ directory that should help get you started.
• another intruder with the mooring in the heart of the Perl
|
|---|