in reply to Sending data for LOOP in HTML::Template

ie. how would you store the selected column header's names into $rows, so that the following would work?
I am not sure if I got your question right, but assuming that $rows contains a reference to an Array of Hashes, where they keys are your columnnames like:
my $rows = [ { 'column number 4' => 'data row 1, col 4', 'column number 2' => 'data row 1, col 2', 'column number 5' => 'data row 1, col 5', }, { 'column number 4' => 'data row 2, col 4', 'column number 5' => 'data row 2, col 5', 'column number 2' => 'data row 2, col 2', } ];

you could do
my %rownames; $rownames{$_} = $_ for sort keys %{@{$rows}[0]}; unshift @$rows, \%rownames;
to add an additional row at the top which contains the hash keys as values
[ { 'column number 2' => 'column number 2', 'column number 5' => 'column number 5', 'column number 4' => 'column number 4' }, # ...