perl - Ignoring GET error of an unexisting webpage -
i use www::mechanize
fetch , process web pages. have piece of code, looping through list of web pages. looks approximately this:
while (<$readfilehandle>) { $mech->get("$url"); }
now problem occurs when 1 of web pages in list not exist reason(which ok). issue in case - program returns error , exits. error looks that:
error geting <url> not found @ <path/file.pl> line ...
how can ignore such type of error? want program keep running.
you need use eval {};
this:
while ( $url = readline($readfilehandle) ) { chomp $url; eval { $mech->get($url); }; if ($@) { #error processing code } }
Comments
Post a Comment