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

Every once in a while, I'm getting a "GET" error on my program. I am fairly certain it is the website that is down. Rather than stopping the program and throwing off this error, is there a way to simply restart the program from the top? Thanks!
I love it when a program comes together - jdhannibal
  • Comment on WWW::MECHANIZE Get Errors Ending Program Early?

Replies are listed 'Best First'.
Re: WWW::MECHANIZE Get Errors Ending Program Early?
by Corion (Patriarch) on Feb 09, 2010 at 19:38 UTC

    The module's name is WWW::Mechanize. Perl is picky about the capitalization of module names, so it's better to use a consistent, and preferrably the correct way of writing a module name.

    The WWW::Mechanize documentation points out the autocheck parameter that you can give to the constructor if you promise to check the results of your calls to ->get etc. yourself.

Re: WWW::MECHANIZE Get Errors Ending Program Early?
by pileofrogs (Priest) on Feb 09, 2010 at 20:38 UTC

    The really generic way to do it would be to stick it in a loop and eval { } your get call.

    In Perl, eval { } is what you use to catch exceptions. See eval.

Re: WWW::MECHANIZE Get Errors Ending Program Early?
by zentara (Cardinal) on Feb 10, 2010 at 18:07 UTC