my @names = qw[ Date Type Amount Ending_balance ] ; my @transactions; ... while ... my @row = split '&', $_; my %hashrow; @hashrow{ @names } = @row; push @transactions, \%hashrow ... $template->param(TRANSACTIONS => \@transactions );