I just recently learned about HTML::Lint from petdance's journal. I immediately wanted to integrate it into my latest web project. Here's how I did it using CGI::Application's new cgiapp_postrun() method in my CGI::Application super-class:
# check for HTML errors
sub cgiapp_postrun {
my ($self, $o) = @_;
# parse the output with HTML::Lint
my $lint = HTML::Lint->new();
$lint->parse($$o);
$lint->eof();
# if there were errors put them into a
# new window
if ($lint->errors) {
my $err_text = "!) { $$o =~ s!!$js\n!; } else { $$o .= $js; } } }
Using this code, when one or more HTML errors are detected a new window pops up with the errors in a list. The window is reused on future requests if not closed.
-sam