in reply to using HTML::TreeBuilder causes "premature end" error

You're almost certainly right about the problem. It's very likely that HTML::TreeBuilder is not installed on the server is causing the issue because that's one thing that would cause this. It's possible there's some issue with the way it's installed or it being corrupted, too.

The suggestion to use CGI::Carp qw( fatalsToBrowser ); should help you get an error message. There might also be something in the logs.

You can also, when in doubt, wrap a require() in an eval and then do any importing. This allows you to trap the failure specifically and do custom reporting or even try a different module.

Another way to approach this, which is generally less helpful for debugging but could help in this case, is to look in your hosting support documentation to see which modules are installed. Most hosting accounts with paid hosting services have this, or your company's internal hosting group should be able to tell you.