\n";
print "\n";
print "Date: \n AE: no yes \n";
print "Time: \n am pm \n";
print "Read: \n";
print "
";
# ROUTINE TO MOVE INPUT FILE 'BLOODSUGAR.DAT' TO ARRAY WORKFILE
open (workfile, "; # moving input file reads to the array 'workfile'
close(workfile); # closing file
print "Check 1: Last index for workfile: $#workfile ";
if ($#workfile = -1)
{
print "\ \ \ \ INPUT file is not present ";
}
# END MOVE ROUTINE
# DEFINE SCRIPT VARIABLES
$datecomp = $formdata{'datedata'};
$count = 0;
$founddex = "no";
$fountarraydex = 0;
$am_or_pm = $formdata{'shift'};
$looptrip = 1;
print "Check 2: shift is ' $am_or_pm ' ";
# END OF SCRIPT VARIABLE DEFINITION
# LOOP TO CHECK FOR EXSISTING RECORD
if ($#workfile = -1)
{
print "Loop check is skipped because of no input file "
}
else
{
foreach $listing (@workfile)
{
($arraydate, $morntime, $mornread, $morneaten, $noontime, $noonread, $nooneaten) = split(/-/, $listing);
print "Array Date is: $arraydate ";
if ($arraydate eq $datecomp)
{
print "Check 3: (date compare) $arraydate vs $datecomp ";
if ($am_or_pm eq "am")
{
$morntime = $formdata{'$timedata'};
$mornread = $formdata{'$readdata'};
$morneaten = $formdata{'$eaten'};
}
else
{
$noontime = $formdata{'$timedata'};
$noonread = $formdata{'$readdata'};
$nooneaten = $formdata{'eaten'};
}
$foundarraydex = $count;
$founddex = "yes";
$count = $count + 1;
$amendedrecord = $arraydate."-".$morntime."-".$morneaten."-".$noontime."-".$noonread."-".$nooneaten;
print "Amended Record: $amendedrecord ";
$workfile[$foundarraydex] = $amendedrecord;
}
print "Loop Cycled ";
}
print "No Matching Record ";
}
# END LOOP
# ROUTINE FOR NEW RECORD
print "New Record Routine Founddex = $founddex "
if ($founddex eq "no")
{
if ($am_or_pm eq "am")
{
$morntime = $formdata{'$timedata'};
$mornread = $formdata{'$readdata'};
$morneaten = $formdata{'$eaten'};
$noontime = "N/A";
$noonread = "N/A";
$nooneaten = "N/A";
}
else
{
$noontime = $formdata{'$timedata'};
$noonread = $formdata{'$readdata'};
$nooneaten = $formdata{'eaten'};
$morntime = "N/A";
$mornread = "N/A";
$morneaten = "N/A";
}
$appendedrecord = $arraydate."-".$morntime."-".$mornread."-".$morneaten."-".$noontime."-".$noonread."-".$nooneaten;
$newdex = $#workfile;
++$newdex;
$workfile[$newdex] = $appendedrecord;
print "new record check ";
}
#open (extfile, ">>bloodsugar.dat");
#@workfile = sort{$b comp $a}(@workfile);
#foreach $outputrec (@workfile)
# {
# print extfile "$outputrec/n";
# }
# END NEW RECORD ROUTINE
# DISPLAY LOOP FOR ARRAY'S ENTIRES
#foreach $listing (@workfile)
#{
#($morndate, $morntime, $mornread, $morneaten, $noontime, $noonread, $nooneaten) = split(/-/, $listing);
#print "$morndate $morntime a.m. $mornread | $noonread $noontime p.m. ";
#}
# END LOOP
# BEGIN ROUTINE TO PRINT STATIC PORTION OF WEB PAGE
print "\n | \n";
print " | \n";
print "\n";
print " \n";
print " \n";
print " | \n";
print "
\n";
print "