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

Re: [ID 20000919.002] Infinite Loop In Regexp Machinery

Thread Previous | Thread Next
From:
Hugo
Date:
September 19, 2000 16:47
Subject:
Re: [ID 20000919.002] Infinite Loop In Regexp Machinery
Message ID:
200009192348.AAA14076@crypt.compulink.co.uk
In <200009192333.e8JNXpZ05421@mail.hispeed.net>, 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
possibilities.

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.)

Hugo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About