sub generate { my $hashref = shift; my $template = HTML::Template->new(filename => "$tmpldir/generic.tt"); $template->param(map { defined $hashref->{$_} ? ($_ => $hashref->{$_}) : () } keys %$hashref); ); print $template->output; }