执行perl脚本

时间:2013-12-06 07:12:29

标签: perl apache

我正在尝试从命令行运行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";
}

错误

  1. C:/vhosts/phpcs5/googly.pl第19行似乎缺少分号。
  2. C语言错误:/vhosts/phpcs5/googly.pl第17行,靠近“wsdl my”
  3. 全局符号“$ google_search”需要在C的显式包名:/vhosts/phpcs5/googly.pl第17行
  4. 全局符号“$ google_search”需要在C:/vhosts/phpcs5/googly.pl第19行显式包名称
  5. C语言错误:/vhosts/phpcs5/googly.pl第20行,靠近“doGoogleSearch”
  6. 执行C:/vhosts/phpcs5/googly.pl因编译错误而中止。

1 个答案:

答案 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");