in reply to Making a hash of making a hash of an array

Interesting problem. I really wish you would have supplied your template as well as your flat text file, as you didn't, i'll have to make up my own. ;) I chose to use Tie::File, even though my first instincts were to use File::ReadBackwards. I chose Tie::File because i'd rather work with an array slice, that's all. There are two lines that print two important datastructures to STDERR -- understanding what you datastructure should look like is the key in getting the hang of loop with HTML::Template. You don't have to use map as i have done, i just wanted to show you that Perl can be quite consise. (Make sure that the entire DATA section is included in the script if you copy this.)
use strict; use warnings; use Tie::File; use Data::Dumper; use HTML::Template; # part 1: get the last ten lines and store in a 2-D array my @record; tie @record, 'Tie::File', 'record.txt' or die $!; my @last10 = map [split "\t"], @record[map -$_,1..10]; #print STDERR Dumper \@last10; # part 2: create a list of hashes (LoH) for HTML::Template my %hash; my @headers = qw(date amount action total); my @loop = map { @hash{@headers} = @$_[1..@$_]; # exclude timestamp $_ = {%hash} } sort {$a->[0] <=> $b->[0]} @last10; # sort by timestamp #print STDERR Dumper \@loop; # part 3: shove data through template my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param(member => \@loop); print $tmpl->output; __DATA__ <table> <tr> <th>Date</th> <th>Amount</th> <th>Action</th> <th>Total</th> </tr> <tmpl_loop member> <tr> <td><tmpl_var date></td> <td><tmpl_var amount></td> <td><tmpl_var action></td> <td><tmpl_var total></td> </tr> </tmpl_loop> </table>
record.txt is a tab delimited file similar this one that i used for testing:
1054703890	a	b	c	d
1054703892	e	f	g	h
1054703894	1	2	3	4
1054703896	5	6	7	8
1054703891	A	B	C	D
1054703893	E	F	G	H
1054703895	my	how	time	flies

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)