我正在尝试从命令行运行perl脚本'googly.pl',它会给出一些错误。这是脚本和错误。我已经重新检查了脚本,但我仍然无法成功运行脚本。
#!C:\Strawberry\perl\bin\perl.exe
# googly.pl
# A typical Google Web API Perl script
# Usage: perl googly.pl <query>
# Your Google API developer's key
my $google_key='';
# Location of the GoogleSearch WSDL file
my $google_wdsl = "C:/vhosts/phpcs5/GoogleSearch.wsdl";
use strict;
# Use the SOAP::Lite Perl module
use SOAP::Lite;
# Take the query from the command-line
my $query = shift @ARGV or die "Usage: perl googly.pl
<query>\n";
# Create a new SOAP::Lite instance, feeding it
GoogleSearch.wsdl
my $google_search = SOAP::Lite->service("file:$google_wdsl");
# Query Google
my $results = $google_search ->
doGoogleSearch(
$google_key, $query, 0, 10, "false", "", "false",
"", "latin1", "latin1"
);
# No results?
@{$results->{resultElements}} or exit;
# Loop through the results
foreach my $result (@{$results->{resultElements}}) {
# Print out the main bits of each result
print
join "\n",
$result->{title} || "no title",
$result->{URL},
$result->{snippet} || 'no snippet',
"\n";
}
错误
答案 0 :(得分:4)
my $query = shift @ARGV or die "Usage: perl googly.pl
<query>\n";
# Create a new SOAP::Lite instance, feeding it
GoogleSearch.wsdl
my $google_search = SOAP::Lite->service("file:$google_wdsl");
应该是
my $query = shift @ARGV or die "Usage: perl googly.pl <query>\n";
# Create a new SOAP::Lite instance, feeding it GoogleSearch.wsdl
my $google_search = SOAP::Lite->service("file:$google_wdsl");