my %templates; # some code sub include { my $tpl = shift; $templates{$tpl} ||= fetch($tpl); return $tpl; } sub fetch { my $tpl = shift; local (*TPL, $/); open(TPL, "template_folder/$tpl") or return; return ; }