Search code examples
perllwp

Got error using LWP


I was trying to use LWP in perl, and I followed the example given in the link:http://www.perl.com/pub/2002/08/20/perlandlwp.html,

But I got errors as such:

"www.google.com" is not exported by the LWP::Simple module

Can't continue after import errors at /System/Library/Perl/Extras/5.12/LWP/Simple.pm line 23

And here is my code:

      #!/usr/bin/perl -w
     use LWP::Simple

    $url = 'www.google.com';
    $content = get $url;

Am I doing something wrong here?


Solution

  • You need a semicolon after your use statement, and your URL needs to have a protocol specified.

     #!/usr/bin/perl
     use LWP::Simple;
    
     use strict;
     use warnings;
    
     my $url = 'http://www.google.com';
     my $content = get $url;