in reply to really large regex misbehaving

Two things: don't use a regex, but if you do, try debugging it with re 'debug'.

Don't use a regex: you're not actually matching text here, you're trying to parse it. Use Parse::RecDescent or something similar to parse data like this. Regular expressions are powerful, but I don't think they're really suited to the task at hand.

If you must stick with a regex, reduce the text to the absolute minimum that gives you unexpected results and use re 'debug'. Read the output on the following to get a feel for how it works:

use strict; use re 'debug'; my $test = "123avc 8c7d45"; $test =~ /(c[^c]+d)/; print $1;

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.