in reply to Re: Regex infinite loop?
in thread Regex infinite loop?

I understand that I have given you very little to go on. I'm thinking that it's neither a network problem or a server problem because it always hangs on the same page. Even when I change the order in which I retrieve the pages, it still hangs on the same page. So, it seems like the problem is page-specific.

I also have a line immediately following my {Do something} block that let's me know that I've exited the match. On the pages where my code hangs, it never exits the {Do something} block.

On the time to match part, the match happens fairly quickly whether or not there are zero matches, one match, or multiple matches.

One thing I should probably have mentioned, but neglected to, is that I've been running this code for a while now (it runs automatically once a day). Whoever runs the website that I'm pulling from made some minor changes to the HTML, so I needed to go back and change my matching pattern. But, like I said, it matches fine on some web pages, but then hangs on others.

Replies are listed 'Best First'.
Re^3: Regex infinite loop?
by moritz (Cardinal) on Oct 16, 2008 at 18:41 UTC
    Talk code. Show us the regex, and the data on which it hangs.
Re^3: Regex infinite loop?
by JavaFan (Canon) on Oct 16, 2008 at 21:27 UTC
    But if it "hangs" does it hang in the loop? You've code showing it exits the loop, but do you know it entered the loop? What I would do is first determine where the program "hangs": print a message before fetching a page; print a message after the page was retrieved; print a message before attempting the pattern; print a message when entering the body of the while; print a message just before exiting the body; print a message when exiting the while construct.

    And to avoid buffer problems, print those messages to STDERR.