use strict; use warnings; use Template; my $template = Template->new({ INCLUDE_PATH => '.', EVAL_PERL => 1, }) || die $!; my $foo = foo(3,5); my @s = ('this', 'that'); $template->process("tpl.txt", {foo => $foo, s => \@s}) || die $template->error(); sub foo { $_[0]+$_[1] }