#! /usr/bin/perl -wT use strict; use warnings; use CGI qw/:standard :delete_all :escapeHTML :html3 :all/; use HTML::Template; # Get the data as array of hashes my $show_vars = get_data( ); print header; my $template = HTML::Template->new( filename => 'temp.tmpl' ); $template->param( show_vars => $show_vars ); print $template->output(); # subroutine to create the data structure sub get_data{ my @AoH = ( { Lead => "fred", Friend => "barney", Son => "", No => "1", }, { Lead => "george", Wife => "jane", Son => "elroy|sam|bobby", No => "2", } ); return ( \@AoH ); }