in reply to How regexes fail.

The first thing that comes to mind is to have a bunch of optional captures.

while (1) { $foo .= <HANDLE> $foo =~ /(bar(baz(buz)?)?)/; print "bar found\n" if defined $1; print "baz found\n" if defined $2; print "buz found\n" if defined $3; last if defined $3; }

Of course this could get really ugly if you have big, complex regexes to work with. I'm willing to bet that there are other caveats as well, but I'm not sure what they might be.


TGI says moo