Reputation: 313
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?
Upvotes: 0
Views: 307
Reputation: 29854
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.
Upvotes: 0
Reputation: 67058
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;
Upvotes: 2