2

i am very new to Perl however i was bit expertise in using perl modules i have worked on HTML::table extract but when i dealing with Mechanize module its keep saying me that CAN'T Locate object method "new" via package" while running the below program

    #!user/Perl/bin;
                 use strict;
                 use warnings;
                 use WWW::Mechanize;
                 my $URL ="https://accounts.google.com"   
                 my $username = <>;
                 my $password = <>;
                 my $mech =new  www::Mechanize();
                 $mech -> get($url);
$mech -> form_name('formname');
$mech -> field ('username' =>$username);
$mech -> field ('password' =>$password);
$mech -> click('signin');

i also been to some of guide lines given by stack overflow members and installed Mechanize::Firefox as well by following below steps

cpan WWW::Mechanize::Firefox
cpan MozRepl
cpan MozRepl::RemoteObject

however i keep getting the same error while running my code

please help me here..

Thanks N@veen

Karthik T
  • 31,456
  • 5
  • 68
  • 87
user2106358
  • 21
  • 1
  • 2
  • As a side note: [How to do the shebang line right](http://stackoverflow.com/questions/2791954/what-should-i-use-for-a-perl-scripts-shebang-line) – memowe Feb 25 '13 at 14:07

1 Answers1

10

Perl is case-sensitive. www::Mechanize is not the same as WWW::Mechanize (the latter has capital W's).

You're loading (upper-case) WWW::Mechanize and then trying to create an object of class (lower-case) www::Mechanize, which doesn't exist.

Also, it's generally considered best to avoid indirect-object syntax. That is, use

my $mech = WWW::Mechanize->new();

instead of

my $mech = new WWW::Mechanize();

(But that wasn't the cause of your problem.)

cjm
  • 61,471
  • 9
  • 126
  • 175
  • I appreciate your help now i can able to run my script . just wanted to know about follow_link() what it will do exactly – user2106358 Feb 25 '13 at 20:12