in reply to Determining which pattern matched
Don't capture into a single set of parens; use a set for each chunk you want distinguishable and then look in @- and figure out which one matched.
$ perl -MYAML::Syck=Dump -le '$_="fum";/(fee)|(fie)|(foe)|(fum)/;print + Dump( \@- );print "paren ", grep( defined $-[$_], 1..4), " matched"' --- - 0 - ~ - ~ - ~ - 0 paren 4 matched
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Determining which pattern matched
by Anonymous Monk on Apr 02, 2010 at 23:02 UTC |