Perl

Moderators: Jonathan
Number of threads: 1236
Number of posts: 3605

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Errors viewing perl editor Posted by spanish26 on 20 Jan 2009 at 2:31 AM


Hello,

Please i need some assistance running a perl script, i obtained a Google API key, installed a a perl editor to run the program, The server for the program went down,so this is the only way to access the application, however i experience errors when debugging the program on my computer

The errors are:

Useless use of a constant in void context at Untitled line 12 "SOAP::Lite" ;
Use of uninitialized value in concatenation(.) or string at (eval 8) line 15 " use List ::Until qw(max min)" ;

Use of uninitialized value in concatenatiom(.) or string at Untitled line 62 " $x = '+" ' . $query->param('term1') . ' " " ;

Use of uninitialized value in concatenatiom(.) or string at Untitled line 63 " $x = '+" ' . $query->param('term2') . ' " " ;

Can`t locate object method "service" via package "SOAP::Lite" (perhaps ypu forgot to load "SOAP::Lite"?) at Untitled line 30.

This are the errors displayed on the browser.

This is the source code for the program :

#!"C:\Program Files\xampp\perl\bin\perl.exe"
# ngd-calculator.cgi
#
# wjt
# http://history.uwo.ca/faculty/turkel/
#
# 5 aug 2006

use SOAP::Lite;
use CGI;
use POSIX qw(log10);
use List::Util qw(max min);

# Google API developer's key
my $google_key = '<Insert Key Here>';

# Google WSDL
my $google_wsdl = "http://api.google.com/GoogleSearch.wsdl";
# my $google_wsdl = "./GoogleSearch.wsdl";

# start, maxResults, filter, restrict, safeSearch, lr, ie, oe
my @params = (0, 10, 0, '', 0, '', 'utf-8', 'utf-8');

# Do Google search and return count
sub do_search {
unshift (@params, ($google_key, $_[0]));
my $result =
SOAP::Lite
-> service($google_wsdl)
-> doGoogleSearch(@params);
shift @params;
shift @params;
return $result->{estimatedTotalResultsCount};
}

# Create the search page
$query = new CGI;
print $query->header;
print $query->start_html('NGD Calculator');
print "<H1>Normalized Google Distance (NGD) Calculator</H1>";

print '<p>';
print 'For information about NGD see Rudi Cilibrasi and Paul Vitanyi, "';
print '<a href="http://www.arxiv.org/PS_cache/cs/pdf/0412/0412098.pdf">';
print 'Automatic Meaning Discovery Using Google</a>."';
print '</p>';

# Print the search box form
print $query->startform;
print '<strong>Enter term 1</strong> ',$query->textfield('term1');
print '<br />';
print '<strong>Enter term 2</strong> ',$query->textfield('term2');
print '<br />';
print $query->submit('form_1','Calculate');
print $query->endform;
print '<br />';

$x = ''; $y = ''; $xy = '';
$x = '+"' . $query->param('term1') . '"';
$y = '+"' . $query->param('term2') . '"';
$xy = $x . " " . $y;

$fx = 1; $fy = 1; $fxy = 1;
$logfx = 0; $logfy = 0; $logfxy = 0; $logm = 0;
$maxlogfxy = 0; $minlogfxy = 0;
$ngd = 0;

# Best guess as of Jan 2006
$m = 11828505634;

if ($x && $y) {

# Determine frequencies
$fx = do_search( $x );
$fy = do_search( $y );
$fxy = do_search( $xy );

# Determine logarithms
$logm = log10( $m );
$logfx = log10( $fx );
$logfy = log10( $fy );
$logfxy = log10( $fxy );

# Determine max and min
@fxy = ($logfx, $logfy);
$maxlogfxy = max @fxy;
$minlogfxy = min @fxy;

# Calculate NGD
$ngd = ($maxlogfxy - $logfxy) / ($logm - $minlogfxy);

print 'NGD(x,y) = ' . $ngd . '<br /><br />';

print 'Term 1: ' . $x . '<br />';
print 'f(x) = ' . $fx . '<br />';
print 'log f(x) = ' . $logfx . '<br /><br />';

print 'Term 2: ' . $y . '<br />';
print 'f(y) = ' . $fy . '<br />';
print 'log f(y) = ' . $logfy . '<br /><br />';

# print 'max(log f(x),log f(y)) = ' . $maxlogfxy . '<br />';
# print 'min(log f(x),log f(y)) = ' . $minlogfxy . '<br /><br />';

print 'Intersection: ' . $xy . '<br />';
print 'f(x,y) = ' . $fxy . '<br />';
print 'log f(x,y) = ' . $logfxy . '<br /><br />';

print 'M: ' . $m . '<br />';
print 'log M: ' . $logm . '<br />';
}

print qq{<P><A HREF="http://history.uwo.ca/faculty/turkel">Digital History at Western</A>};
print $query->end_html;

Please any assistance is highly appreciated, because i am meant to use the application for a research presentation soon. Please

Thank you
Spanish

Report
Re: Errors viewing perl editor Posted by leeb003 on 20 Jan 2009 at 10:24 PM
It works for me when run on a linux box...at least the form loads correctly in cgi with no errors, I don't know about the rest of what you are doing. Are you pointing to your correct perl location and do you have the module SOAP::Lite installed correctly? What version perl do you have ... perl -v .
Report
Re: Errors viewing perl editor Posted by spanish26 on 21 Jan 2009 at 12:04 AM
I am running on windows Xp and the version is DZSoft.Perl.Editor. v5.8.3.7-iN and OptiPerl-5.4 Trial, i have installed the SOAP-Lite in the directory.
just like you mentioned is to display the user interfaces with the boxes in it(forms)and perform calculation between the terms
"Enter term 1 and Enter term 2, using the calculate button.
I ran the program and i got the forms but the calculation does not return any value, when the calculate button is clicked

Thank you

Spanish



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.