$ cat /tmp/html-data.pl #!/usr/bin/perl use strict; use warnings; use HTML::Template; use File::Basename; my($script, $path) = fileparse($0); # the use of load_page() is intentional my $template = load_page(\*DATA); $template->param( script => $script, path => $path, pid => $$, ); print $template->output; sub load_page { my $fh = shift; HTML::Template->new(filehandle => $fh); } __DATA__ Hi, I'm script , located at running with process id $ perl /tmp/html-data.pl Hi, I'm script html-data.pl, located at /tmp/ running with process id 4291