Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: WWW::Mechanize follow_link() crashes if no link is found

by arkturuz (Curate)
on Sep 25, 2009 at 11:47 UTC ( #797465=note: print w/ replies, xml ) Need Help??


in reply to WWW::Mechanize follow_link() crashes if no link is found

It's seems to me it's a feature actually and not a bug. Quote from the Changes for version 1.51_03:

$mech->follow_link() did not complain if a link could not be found, even with autocheck on. Now it does. Thanks, Flavio Poletti.


Comment on Re: WWW::Mechanize follow_link() crashes if no link is found
Download Code
Re^2: WWW::Mechanize follow_link() crashes if no link is found
by venkatesan_G02 (Sexton) on Sep 25, 2009 at 11:54 UTC
    Hi,

    First thanks for the reply.

    But, Pardon me for my ignorance. I didn't get your point.

    Is there any way to make my program move on with the next step rather than crashing at follow_link line?

    Thanks
      Well, one way would be to always pass a valid link to be followed. The other would be, as is specified in the WWW::Mechanize docs, to set autocheck to 0. Although, this would silence all requests unless they're errors.
      Is there any way to make my program move on with the next step

      If all else fails, you could trap the exception, i.e. wrap the call within eval { ... } — Something like this

      my $foo; # undefined eval { $foo->url(); # would 'Can't call method "url" on an undefined val +ue ...' }; if ($@) { # ... handle the exception print "error: ...: $@\n"; }
        Thanks almut.... It worked.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://797465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2014-07-31 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (252 votes), past polls