Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

perl lwp question on windows


I've just installed ActivePerl on a windows 2000 machine.  When I run "c:\perl -v" it returns v5.8.4.  If I run "c:\perl -MLWP -le "print(LWP->VERSION)" it returns 5.79.  And when I run "c:\perl -MURI -le "print $URI::VERSION" it returns 1.30.

However, when I run the following program:

use Strict;
use warnings;

use LWP;

my $browser = LWP::UserAgent->new();
my $response = $browser->get("http://www.oreilly.com/");
print $response->header("Server"), "\n";

(from the book "Perl & LWP") I receive the following error:

"c:\perl -w example.pl"
Can't locate object method "new" via package "LWP::userAgent" (perhaps you forgot to load "LWP::userAgent"?) at example.pl line 7

If I change the code to "use LWP::UserAgent;"   I still get the same error.

Could it be a path problem perhaps?


1 Solution
You say your code is
my $browser = LWP::UserAgent->new();
with a capital "U"
Yet the error message says "LWP::userAgent"
with a lower case "u"
Did you spell "UserAgent" correctly?
pennypiperAuthor Commented:
That's it!  I had indeed misspelled UserAgent.  Thank-you!

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now