in reply to How to find where regex did not match across the line

A possibly useful addendum to the excellent guidance above( if you were to break up your regex to find a series of partial matches): perlvar and seek down for '$`', the postmatch variable.
The string following whatever was matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK).
...

The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. To avoid this penalty, you can extract the same substring by using @-. Starting with Perl 5.10, you can use the

match flag and the ${^POSTMATCH} variable to do the same thing for particular match operations.

This variable is read-only and dynamically-scoped.

See also ${^POSTMATCH} for a way to avoid the performace penalty.

  • Comment on Re: How to find where regex did not match across the line

Replies are listed 'Best First'.
Re^2: How to find where regex did not match across the line (postmatch)
by tye (Sage) on Mar 12, 2012 at 20:10 UTC

    The word "match" being in the name "POSTMATCH" was not an accident. It is completely useless for a case of "not matching".

    - tye        

      The conditional, "if you were to break up your regex to find a series of partial matches," was not an accident either.

      Were OP to use postmatch to find the last partial that succeeded, he would have at least an initial indication of where the failure occured.