ufizo has asked for the wisdom of the Perl Monks concerning the following question:

I have just started learning Mechanize, but am getting the following errors while calling its methods:
require WWW::Mechanize; my $mech = new WWW::Mechanize; $page = $mech->get("http://www.google.com"); $page->find_link(text => 'download');
I get the following error:
Can't locate object method "find_link" via package "HTTP::Headers" at +C:/Perl/lib/HTTP/message.pm line 649.
Im not sure what to do,..

Replies are listed 'Best First'.
Re: Cant get Mechanize to work.
by Corion (Patriarch) on Jul 10, 2011 at 09:00 UTC
      yes i understand that, but the code that i am running is giving me a error pointing to HTTP::Header !

        That happens because you are using the object in ways not documented by the WWW::Mechanize documentation. Please re-read the documentation on ->get and what the method returns. You have the following code:

        $page = $mech->get("http://www.google.com");

        This usage is nowhere documented.

        Also see the documentation on ->find_link. It shows the following example:

        $mech->find_link( n => $number );

        Note how the method is called on a variable named $mech.