use Template::Alloy; use POSIX qw(tmpnam); my $file1 = tmpnam; my $file2 = tmpnam; END { unlink $file1 }; END { unlink $file2 }; if (open my $fh, ">", $file1) { print $fh "I am file1 ($file1). title = (). page = (). ------------------ ------------------ "; close $fh; } if (open my $fh2, ">", $file2) { print $fh2 "I am file2 ($file1). title = (). "; close $fh2; } my $ht = Template::Alloy->new(filename => $file1, absolute => 1); $ht->param(title => 'The title'); $ht->param(page => $file2); $ht->param(page3 => sub { "This is a dynamically included string.\ntitle = ()\n"}); print $ht->output; __END__ prints I am file1 (/tmp/filessyE4j). title = (The title). page = (/tmp/filez6O6TO). ------------------ I am file2 (/tmp/filessyE4j). title = (The title). ------------------ This is a dynamically included string. title = (The title)