Question

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?

Was it helpful?

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;

OTHER TIPS

Yes. You missed the semicolon after use LWP::Simple.

Had you used strict it would have told you that you have to declare $url. But if you declared both variables, you would still have gotten the error you did.

So, it's not a simple case of USUW.

Because you didn't put a semi-colon after the import statement, perl is assigning the string 'www.google.com' to the autovariable $url. And then, as it is an expression that can be passed, it passes that value as an export arguments of LWP::Simple.

Modules expect that any values passed as arguments to its import process, are symbols that the module--or Exporter--knows how to export.

So it's telling you that the whatever that string that you passed in is, it's not something that the module exports.

So, you just have to get used to this type of message pointing out that something is wrong with your import statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top