user3062701
user3062701

Reputation: 31

execution of perl script

I am trying to run a perl script 'googly.pl' from the command line, and it is giving some errors. Here is the script and the errors. I have re-checked the script, but I am still unable to successfully run the script.

#!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";
}

Errors

  1. Semicolon seems to be missing at C:/vhosts/phpcs5/googly.pl line 19.
  2. Syntax error at C:/vhosts/phpcs5/googly.pl line 17, near "wsdl my "
  3. Global symbol "$google_search" requires explicit package name at C:/vhosts/phpcs5/googly.pl line 17
  4. Global symbol "$google_search" requires explicit package name at C:/vhosts/phpcs5/googly.pl line 19
  5. Syntax error at C:/vhosts/phpcs5/googly.pl line 20, near "doGoogleSearch"
  6. Execution of C:/vhosts/phpcs5/googly.pl aborted due to compilation errors.

Upvotes: 0

Views: 144

Answers (1)

ikegami
ikegami

Reputation: 385645

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

should be

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

Upvotes: 4

Related Questions