in reply to WWW::Mechanize agent timing-out from server

What if you change the for to a while (@dates) and then simply shift the dates out of your array when each one is successfully processed?

That way, @dates will always contain the remaining work, and if there is a failure, you simply do not shift the array. (Or push the value back on after you shift it, so if there are impossible dates, you won't get stuck on it until after all good dates are done.)

  • Comment on Re: WWW::Mechanize agent timing-out from server

Replies are listed 'Best First'.
Re^2: WWW::Mechanize agent timing-out from server
by cheech (Beadle) on Jul 28, 2009 at 21:10 UTC
    I see what you mean, but this still does not help me automatically restart the program if it gets timed-out. I need to make it all the way up to 2009...?

      You should not restart the program. Simply continue instead of dying.

      If you need to trap Mechanize dying, then consider the use of eval

        Would this work in the same way as WWW::Mechanize->success() after submitting the form? I'm still confused on how to restart the loop at the current iteration..
Re^2: WWW::Mechanize agent timing-out from server
by cheech (Beadle) on Jul 29, 2009 at 21:42 UTC
    I apologize if I'm missing something, but I still don't see how this helps me. I believe what I'm after is exception handling.. My Mech agent submits a query to the server and gets disconnected, and I get a fatal error at the command line (server: timeout). I just want to be able to restart at the failed iteration of my loop without having to manually execute the script again..? I can't continue or exit the loop; My program dies upon being disconnected.
      sub myprogram { ... } # your program, which die on error while(1){ if( eval { myprogram(); 1 } ){ print "Program finished without dying, quitting\n"; last; } else { print "uh oh, myprogram() died : $@ \n retrying \n"; } }