in reply to finding comments with HTML::Element

Try setting store_comments before you parse the file:

my $template_tree = HTML::TreeBuilder->new(); $template_tree->->store_comments(1); $template_tree->parse_file (\*TEMPLATE);

Note: the HTML::TreeBuilder documentation says:

$root->store_comments(value)
This determines whether TreeBuilder will normally store comments found while parsing content into $root. Currently, this is off by default.

DWIM is Perl's answer to Gödel