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

Dear Monks,

I do not know why I am getting ...
Can't locate object method "get" via package "LWP::UserAgent" (perhaps + you forgot to load "LWP::UserAgent"?) at ./download.pl line 8.
... error messages. My script (with exception) of the shebag is taken directly from the Synopsis section of LWP::UserAgent on CPAN (see below):
#!/usr/local/iXSD/perl/bin/perl require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('http://search.cpan.org/'); if ($response->is_success) { print $response->content; # or whatever } else { die $response->status_line; }
Do I need to something funky with my @INC? Or is my Perl version too old ...
$ perl -version This is perl, v5.6.1 built for i686-linux ...
Thanks!

Replies are listed 'Best First'.
Re: Can't locate object method "get" via package "LWP::UserAgent"
by almut (Canon) on Oct 17, 2007 at 00:41 UTC

    Maybe your version of LWP is too old. From its "Changes" file:

    2001-05-05 Gisle Aas <gisle@ActiveState.com> Release 5.53_94 (...) - new convenience methods: get/head/post/put

    What does perl -MLWP -le "print LWP->Version" say?

      generally its VERSION :)

        Yes, generally... but in this case the author also supplied a "Version" routine — for those of us who don't like typing all-caps words :)

        (But you're right, for more elaborate usages such as $obj->VERSION($minRequiredVersion) you'd want UNIVERSAL's VERSION.)

      Well looks like that is it ...
      $ perl -MLWP -le "print LWP->Version" 5.53
      ... thanks!
Re: Can't locate object method "get" via package "LWP::UserAgent"
by Gangabass (Vicar) on Oct 17, 2007 at 00:41 UTC

    Hm... Very strange.

    Try to reinstall LWP via CPAN maybe this helps.