my $filter = sub { my $text_ref = shift; $$text_ref =~ s/!!!ZAP_(.*?)!!!//g; }; # open zap.tmpl using the above filter my $template = HTML::Template->new( filename => 'zap.tmpl', filter => $filter); #### sub convert { my $text_ref = shift; $$text_ref =~ s/\[\%=(.*?)\%\]//g; $$text_ref =~ s/\[\%\/(.*?)\%\]/<\/TMPL_$1>/g; $$text_ref =~ s/\[\%(.*?)\%\]//g; }