open (FILE, "$record") or die "can't open $record: $!"; my @record = reverse ; close FILE; foreach my $line (@record) { ($timestamp, $current_time, $funds, $action, $current_funds) = split "\t",$line; while ($count < 10){ $member{$timestamp} = [$current_time, $funds, $action, $current_funds]; $count += 1; } } %member = ( $timestamp => [$current_time, $funds, $action, $current_funds]); my $template = HTML::Template->new(filename => 'temp_late.html'); my @loop; # the loop data will be put in here # fill in the loop, sorted by timestamp foreach my $timestamp (sort keys %member) { # get the other data from the data hash my ($current_time, $funds, $action, $current_funds) = @{$member{$timestamp}}; # make a new row for this data - the keys are names # and the values are the values to fill in the template. my %row = ( date => $current_time, amount => $funds, action => $action, total => $current_funds, ); # put this row into the loop by reference push(@loop, \%row); } # call param to fill in the loop with the loop data by reference. $template->param(member => \@loop); # send the obligatory Content-Type print "Content-Type: text/html\n\n"; # print the template print $template->output;