Forum for users of JoomlaWatch / ExtraWatch for Joomla, Wordpress, Drupal, Magento, Prestashop

JoomlaWatch / ExtraWatch has following features: live real-time visitor statistics, location of your visitors on a map, blocking of users based on bad word list, front-end counters, click heat map, definition of goals and rules, graphs, directory size monitoring, monitoring of increase of database data in time, nightly email reports, interactive HTML5 chart of traffic flow within your website, SEO report with keyword statistics and keyword position trends

Welcome, Guest
Please Login or Register.    Lost Password?

Errors in running perl/cgi script
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Errors in running perl/cgi script
#1801
Errors in running perl/cgi script 7 Years, 8 Months ago Karma: 0
Hello,

I made some adjustments in code to calculate the distance between two words when they are entered in the forms, there is meant to be some results when the calculate button is clicked to give the result, however no value is returned and some errors are displayed at the bottom of the editor.

The source code is below :

#!"C:\Program Files\xampp\perl\bin\perl.exe"
# ngd-calculator.cgi
#
# wjt
# 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 = 'ABQIAAAAq8BnDB5aJz60mWC_JluM4xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRkTxVXeNpC7mBQUY0gn3IXwEK8kw';

# Google WSDL
my $google_wsdl = "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="www.arxiv.org/PS_cache/cs/pdf/0412/04120...quot;>';
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="history.uwo.ca/faculty/turkel">Digital History at Western</A>};
print $query->end_html;


And the errors displayed when i run the program are :

Use of uninitialized value in concatenation (.) or string at NGD.pl line 59.
Use of uninitialized value in concatenation (.) or string at NGD.pl line 60.
Use of uninitialized value in subroutine entry at NGD.pl line 80.
Use of uninitialized value in subroutine entry at NGD.pl line 81.
Use of uninitialized value in subroutine entry at NGD.pl line 82
Use of uninitialized value $fx in concatenation (.) or string at NGD.pl line 95.
Use of uninitialized value $fy in concatenation (.) or string at NGD.pl line 99.
Use of uninitialized value $fxy in concatenation (.) or string at NGD.pl line 106.

Any idea on this

Thank you
spanish (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1

Latest News

Get the latest freelance project announcements
Follow CodeGravity.com

Download ExtraWatch™

ExtraWatch™ FREE is Joomla, Wordpress, Prestashop, Magento plugin with following features: Live Stats, Nightly Email Reports, Goals, Graphs, Anti-spam, History and more