in reply to parsing html file

What you're forgetting is that the parse method of HTML::TreeBuilder (inherited from HTML::Parser) does not process a single, whole HTML document, it processes a chunk; each time you call it, it adds to the current tree. Therefore, you should not do anything with the tree until you're completely done processing the input, after the while loop. So simply move the

$Format->format($TreeBuilder);
line to after the end of the loop.

print HTML::FormatText->new->format( HTML::TreeBuilder->new->parse_fil +e($_)) for @ARGV;
Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.