perlquestion
ted.byers
<p>The title is the error message I find in the apache error logs.</p>
<p>What is especially odd is that there are two different cgi scripts that do basically the same thing, but one works and the other gives this error.</p>
<p>You can even check out the behaviour of the two scripts at these two URLS:</p>
<code>
http://74.15.160.240:8080/cgi-bin/Aresults.cgi
http://74.15.160.240:8080/cgi-bin/calculator.cgi
</code>
<p>The following code producs the error in the title</p>
<code>
sub print_response {
unless ($query->param) {
print "<b>Results</b>";
return;
}
$ticker = $query->param('ticker');
$begin_dt = $query->param('begin_dt');
$end_dt = $query->param('end_dt');
print "<b>FIRST:<br />Ticker: $ticker<br />Start date: $begin_dt<br />End date: $end_dt</b><br /><br />";
use Net::HTTP;
print "<b>SECOND:<br />Ticker: $ticker<br />Start date: $begin_dt<br />End date: $end_dt</b>";
my $s = Net::HTTP->new(HOST => "localhost:5000");
print "<b>THIRD:<br />Ticker: $ticker<br />Start date: $begin_dt<br />End date: $end_dt</b>";
$s->write_request(GET => "/Aresult.pl?ticker=$ticker&begin_dt=$begin_dt&end_dt=$end_dt", 'User-Agent' => "Mozilla/5.0");
($code,$mess, %h) = $s->read_response_headers;
while (1) {
my $buf;
my $n = $s->read_entity_body($buf,1024);
last unless $n;
print $buf;
}
}</code>
<p>But in the other cgi script, the following function works fine.</p>
<code>
sub print_response {
unless ($query->param) {
print "<b>No data has been submitted</b>";
return;
}
$vdate = $query->param('vdate');
$edate = $query->param('edate');
$ot = $query->param('ot');
$ul = $query->param('underlying');
$strike = $query->param('strike');
$dy = $query->param('dividendyield');
$rfr = $query->param('riskfreerate');
$vol = $query->param('volatility');
use Net::HTTP;
my $s = Net::HTTP->new(Host => "localhost:5000");
#my $s = Net::HTTP->new(Host => "192.168.2.104:5000");
$s->write_request(GET => "/calc.pl?&vdate=$vdate&edate=$edate&optiontype=$ot&underlying=$ul&strike=$strike÷ndyield=$dy&riskfreerate=$rfr&vol=$vol",
'User-Agent' => "Mozilla/5.0");
my ($code,$mess, %h) = $s->read_response_headers;
while (1) {
my $buf;
my $n = $s->read_entity_body($buf,1024);
last unless $n;
print $buf;
}
}</code>
<p>Apart from the name of the cgi scripts containing these two functions, and the details of these two functions, the scripts are mostly the same.</p>
<p>The scripts are on the same machine, on the same instance of Apache's httpd (the latest version build for Windows - and I use the latest version of Activestate's Perl)</p>
<p>What can possibly account for the difference int he behvaiour of these two functions.</p>