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

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
  • Comment on Re^2: WWW::Mechanize follow_link() crashes if no link is found

Replies are listed 'Best First'.
Re^3: WWW::Mechanize follow_link() crashes if no link is found
by almut (Canon) on Sep 25, 2009 at 12:12 UTC
    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.
Re^3: WWW::Mechanize follow_link() crashes if no link is found
by arkturuz (Curate) on Sep 25, 2009 at 12:12 UTC
    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.