use strict; use warnings; use CGI (); use HTML::Entities (); eval { # Do counting stuff and make sure it's not failing # and won't matter if it does. }; my $output = $@ ? CGI::h3(HTML::Entities::encode_entities("I haz errerz: $@")) : ""; print CGI::header(), CGI::start_html(), $output, CGI::end_html();