JulioSanchez
Programmer
Hi, I am writing a little perl script here, and I am having a heck of a time figuring out this one error. Whenever I run the script I recieve a premature end of scripture headers error. I've tried manipulating the http headers returned in a number of ways, but I can't seem to get anything to work, and I believe there is something fundamentally wrong with my code. Any assistance would be greatly appreciated, and thanks ahead of time....
here's the code...
____________________________________________________ _ _ _ _
#!/usr/local/bin/perl -w
use English;
use diagnostics;
use strict;
#BEGIN
# {
# open STDERR, ">&STDOUT";
# print "Content-type: text/html\n\n<PRE>";
# }
$| = 1; #this clears out the stdout
my (%inputo); #this declares the hash where the input will go
my (@files);
my ($rfile);
my ($year);
my ($month);
my ($day);
my (@lines);
my ($gillam600);
my ($gillam700);
my ($gillam800);
my ($eureka600);
my ($eureka700);
my ($eureka800);
getInputo (\%insub getInputo
{
my ($hashRef) = shift; #initialize the variable to hold the hash
reference
my ($buffer) = ""; #initialize the buffer to hold info
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #reads in the form
info
foreach (split(/&/, $buffer)) #goes through the whole buffer
where the input is stored
{
my ($key, $value) = split(/=/, $_); #splits up the input
into the date and value
$key = decode($key); #sets the key and value to the
decoded values
$value = decode($value);
$hashRef->{$key} = $value; #sets the key and value in the
hash table
}
}
sub decode
{
$_ = shift; #the decode function which gets rid of all the stars
which represent spaces
tr/+/ /;
s/%(..)/pack('c', hex($1))/eg; #convert any symbols out of hex
back to symbols
return($_);
}
sub mainer
{
opendir (DIR, "~/datas/"
; #open the directory where all
the text files are
@files = sort(grep (/txt$/, readdir(DIR))); #finds all
the text files in the directory
closedir (DIR);
foreach (@files)
{
$rfile = grep (/$year-$month-$day/, $_); #find
the file whos title matches the date
}
if ( ! $rfile )
{
return ($eureka600, $eureka700,
$eureka800, $gillam600, $gillam700, $gillam800);
}
open (FILE, $rfile);
@lines= <FILE>; #read in the desired file
close FILE;
foreach (@lines)
{
$eureka600= grep(/eureka600/, $_); #these loops
search through the
#file to see if
the given strings are
#present
}
foreach (@lines)
{
$eureka700 = grep(/eureka700/, $_);
}
foreach (@lines)
{
$eureka800= grep(/eureka800/, $_);
}
foreach (@lines)
{
$gillam600= grep(/gillam600/, $_);
}
foreach (@lines)
{
$gillam700= grep(/gillam700/, $_);
}
foreach (@lines)
{
$gillam800= grep(/gillam800/, $_);
}
return ($eureka600, $eureka700, $eureka800, $gillam600,
$gillam700, $gillam800);
#returns the variables back to the javascript
program..
print "Location: ~/public_html/data1.html\n\n"; #the document we
want the info passed to
print "Window-target: sites\n\n"; #the frame where we want the
html doc to appear
}
_______________________________________________ _ _ _
here's the code...
____________________________________________________ _ _ _ _
#!/usr/local/bin/perl -w
use English;
use diagnostics;
use strict;
#BEGIN
# {
# open STDERR, ">&STDOUT";
# print "Content-type: text/html\n\n<PRE>";
# }
$| = 1; #this clears out the stdout
my (%inputo); #this declares the hash where the input will go
my (@files);
my ($rfile);
my ($year);
my ($month);
my ($day);
my (@lines);
my ($gillam600);
my ($gillam700);
my ($gillam800);
my ($eureka600);
my ($eureka700);
my ($eureka800);
getInputo (\%insub getInputo
{
my ($hashRef) = shift; #initialize the variable to hold the hash
reference
my ($buffer) = ""; #initialize the buffer to hold info
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #reads in the form
info
foreach (split(/&/, $buffer)) #goes through the whole buffer
where the input is stored
{
my ($key, $value) = split(/=/, $_); #splits up the input
into the date and value
$key = decode($key); #sets the key and value to the
decoded values
$value = decode($value);
$hashRef->{$key} = $value; #sets the key and value in the
hash table
}
}
sub decode
{
$_ = shift; #the decode function which gets rid of all the stars
which represent spaces
tr/+/ /;
s/%(..)/pack('c', hex($1))/eg; #convert any symbols out of hex
back to symbols
return($_);
}
sub mainer
{
opendir (DIR, "~/datas/"

the text files are
@files = sort(grep (/txt$/, readdir(DIR))); #finds all
the text files in the directory
closedir (DIR);
foreach (@files)
{
$rfile = grep (/$year-$month-$day/, $_); #find
the file whos title matches the date
}
if ( ! $rfile )
{
return ($eureka600, $eureka700,
$eureka800, $gillam600, $gillam700, $gillam800);
}
open (FILE, $rfile);
@lines= <FILE>; #read in the desired file
close FILE;
foreach (@lines)
{
$eureka600= grep(/eureka600/, $_); #these loops
search through the
#file to see if
the given strings are
#present
}
foreach (@lines)
{
$eureka700 = grep(/eureka700/, $_);
}
foreach (@lines)
{
$eureka800= grep(/eureka800/, $_);
}
foreach (@lines)
{
$gillam600= grep(/gillam600/, $_);
}
foreach (@lines)
{
$gillam700= grep(/gillam700/, $_);
}
foreach (@lines)
{
$gillam800= grep(/gillam800/, $_);
}
return ($eureka600, $eureka700, $eureka800, $gillam600,
$gillam700, $gillam800);
#returns the variables back to the javascript
program..
print "Location: ~/public_html/data1.html\n\n"; #the document we
want the info passed to
print "Window-target: sites\n\n"; #the frame where we want the
html doc to appear
}
_______________________________________________ _ _ _