On Tue, Aug 10, 2010 at 01:35:55PM +0300, Henrik K wrote: > > Big help was page 20+: > <http://web.archive.org/web/20050515221554/http://birmingham.pm.org/talks/YAPC-Europe-2003-Gems.pdf> > > Basically you need to do something like: > > $pat = qr/\b(([a-z][-a-z]{2,15}[a-z]),? ([a-z][-a-z]{2,15}[a-z]))\b/i; > $check = qr/(?{ $found = $1 if defined $names{lc "$2,$3"} || defined > $names{lc "$3,$2"} })/; > while (<>) { > $found = undef; > /$pat$check(?!)/; > print "$found\n" if defined $found; > }
Blah never mind.. the simpler example there works also, I messed up something trying it.. $pat = qr/\b(([a-z][-a-z]{2,15}[a-z]),? ([a-z][-a-z]{2,15}[a-z]))\b/i; while (<>) { while (/(?=$pat)/g) { print "$1\n"; } } And even slightly better since it doesn't overly backtrack.