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

I su'd as root onto my server and installed the following:

HTTP::Cookies (was already up to date)
WWW::Mechanize
WWW::Mechanize::Frames
LWP::Simple

I have a program that uses all three of them.

Here's the thing - on my personal server, my program works perfectly. It logs into a site for me, fills out a form and then submits it.

At work, where I am right now, I have the same program, but when I run it I get the error:

'Can't locate object method "form" via package "WWW::Mechanize::Frames" at myprogram.pl line 41.'

Here is some of the code from the program. Line 41 is commented below:

my $m = WWW::Mechanize::Frames->new( autocheck=>1); $m->get("http://www.mysite.com/"); my $html = $m->content; $html =~ s[</body>][$form_data]g; $m->update_html($html); $m->form('LoginForm'); ## Line 41 $m->field('login','xxxxxxxx'); $m->field('password','xxxxxx'); $m->click();

Any idea why this is happening? Is there a module that I'm missing?

My personal server has perl v5.8.8 built for i686-linux. My job/work server has perl v5.8.6 built for x86_64-linux-thread-multi

I need this program to run on my server at work, not my personal one and I know the program is fine since I've tested and debugged on my personal server. Please reply to this thread if you are able to help me solve this problem.
Thank you in advance

Replies are listed 'Best First'.
Re: Can't locate object error
by Corion (Patriarch) on May 21, 2008 at 15:20 UTC

    A oneliner just popped into my head:

    perl -le "sub UNIVERSAL::versions{ no strict 'refs'; printf qq(%s: %s\ +n), $_, ${$_.qq(::VERSION)}for @{ref $_[0].'::ISA'}}; $_->versions fo +r @ARGV" WWW::Mechanize WWW::Mechanize::Frames

    Most likely the version of one of the modules is too old.

      I changed $m->form to $m->form_name and it now works.

      So the module was installed successfully after all, but I guess things have changed and 'form' isn't accepted anymore. It could be that my personal server is running an old instance of WWW::MEchanize and thus 'form' works. Whereas on my work server which has the newest installation of wWW::Mechanize, 'form' has now been replaced by 'form_name'. Thanks

      But I just installed the most recent version of WWW::Mechanize and WWW::Mechanize::Frames .... so how could that be? How could my version be old if I just installed it from cpan using the install command?