#! /usr/bin/perl -w use strict; use Storable qw/freeze thaw/; use CGI ':standard'; my $source; my $destination; my $oldtotal; my $miles; my $date; my $tripdate; my $tripcounter; my $tablesize; my @table; #master array to carry data from previous iterations #my @newdata; #new array to push array-style data into @table #my @tablereform; #new array to take care of spaces in items in @table #my %spaghetti; #to remind myself that my code is horribly convoluted #my %sauce; #to keep spaghetti company #my $i; #for the "for" loop that creates the table my $e; #for the "for" loop that controls the number of elements in @table my $m; #new variable to play with in @table assignments my $n; #ditto as $m my $cookiedata; #outgoing formatted table data comma delimited my $cookiepickup; #incoming cookie data # Now we get our info from the HTML parameters $source = param('source'); $destination = param('destination'); $oldtotal = param('oldtotal'); $tripdate = param('tripdate'); $tripcounter = param('tripcounter'); $cookiepickup = cookie('trip_history'); ********************************************* @table = @{ thaw $cookiepickup }; #this is the problem. ********************************************* # Now we set some controller variables $tablesize = 1; $e = 1; $m = -1; $n = $tripcounter; # Here is the distance database. Can I do this better? if ($source eq 'HHS') { if ($destination eq 'District') { $miles = 6.7} if ($destination eq 'GHS') { $miles = 5} if ($destination eq 'MHS') { $miles = 8.3} } if ($source eq 'GHS') { if ($destination eq 'HHS') { $miles = 5} if ($destination eq 'District') { $miles = 1.7} if ($destination eq 'MHS') { $miles = 3.3} } if ($source eq 'MHS') { if ($destination eq 'District') { $miles = 1.6} if ($destination eq 'GHS') { $miles = 3.3} if ($destination eq 'HHS') { $miles = 8.3} } if ($source eq 'District') { if ($destination eq 'MHS') { $miles = 1.6} if ($destination eq 'GHS') { $miles = 1.7} if ($destination eq 'HHS') { $miles = 6.7} } if ($source ne $destination) { $oldtotal = $miles + $oldtotal; $tripcounter = $tripcounter + 1; push (@table, $tripdate, $source, $destination, $miles); $cookiedata = freeze \@table; # push(@table, @newdata); print qq (Set-cookie:trip_history=$cookiedata \n); print qq (Content-type: text/html\n\n