develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000919.002] Infinite Loop In Regexp Machinery

Thread Previous | Thread Next
September 19, 2000 16:47
Re: [ID 20000919.002] Infinite Loop In Regexp Machinery
Message ID:
In <>, Karl Dahlke writes:
:The following perl program hangs when it evaluates the regexp.

It hasn't actually hung - the nature of the regexp is such that on
failure it takes exponential time to backtrack through the various

You can improve this using the cut operator (?> ... ), by changing
the inner parens to this:

  (?> [^>"']+ | "[^"]*" | '[^']*' )

However the latest release of perl (5.6.0) has some new code to try
and detect these situations. It isn't perfect, but in this case it
does return pretty much instantly even without the cut operator.
(The documentation of the cut operator is also much improved in the
latest release.)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About