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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -