foreach my $tag ( _all_html_tags() ) { eval "sub $tag { return _tag_func(\$tag,\@_); }"; ... # again for end and start tags #### foreach my $tag ( _all_html_tags() ) { *$tag = sub { return _tag_func($tag,@_); } ... #### DB<106> $tmpl = '$#abc#=15' => "\$#abc#=15" DB<107> $placeholder{abc}='str' => "str" DB<108> $tmpl =~ s/#(\w+)#/$placeholder{$1}/g => 1 DB<109> $tmpl => "\$str=15" DB<110> eval $tmpl => 15 DB<111> $str => 15 #### eval sprintf <<'__CODE__', $tag; sub %1$s { "<%1$s>",@_,""; } __CODE__