Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: regex is hanging inside loop, neither going
by Corion (Patriarch) on Dec 21, 2021 at 07:12 UTC

    Please help us help you better and post the problematic script together with its data here.

    Also, make sure that your script is as short as possible while still reproducing the error.

    Your code as posted has 145 lines and lots of regular expressions. Which of the regular expressions is relevant to reproduce the problem and which can be left out?

    Also, in general, consider not using regular expressions (even Perl "regular" expressions) for parsing HTML and instead consider using an HTML parser.

Re: regex is hanging inside loop, neither going
by atcroft (Abbot) on Dec 22, 2021 at 07:35 UTC

    Your code hangs in the getEleMul subroutine when $i hits 32, which appears to be at or around the time it hits the end of the particular <div> you are in. The regex in the while() loop continues to attempt to match $_[1], which is where I believe your headache comes in. (Mine was in trying to read that complicated regex.) I suspect it is the backtracking you are asking the regex engine to do to find another match that is the cause of your issue.

    You might consider dropping in Regexp::Debugger to help debug why the regex issue is occurring.

    Hope that helps.