Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by arkturuz (Curate)
on Sep 25, 2009 at 11:47 UTC ( [id://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.

Replies are listed 'Best First'.
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
      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.
      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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found