# File IsHTMLEmpty.pm:
package IsHTMLEmpty;
use strict;
use warnings;
use Carp qw/croak/;
use base qw/ Exporter /;
use vars qw/ @EXPORT /;
@EXPORT = qw/ &isHTMLEmpty /;
sub isHTMLEmpty( $ ){
my $filename = shift;
return undef
unless -r $filename;
open IN, $filename
or croak $!;
local $/ = undef;
my $html = ;
close IN
or croak $!;
return $html =~ m{]*>\s*}mo;
}
1;
__END__
####
#!/usr/bin/perl
# File test:
use warnings;
use strict;
use lib '/path/to/my/lib_dir/';
use Carp qw/ croak confess /;
use IsHTMLEmpty;
confess "isHTMLEmpty isn't defined. I'm sorry.\n"
unless defined &isHTMLEmpty;
confess "Sorry, this HTML can generate content.\n"
unless isHTMLEmpty './test.html';
print "Ok.\n"
if isHTMLEmpty './test.html';
__END__
####
Titles aren't considered content.