use HTML::Parser;
my(%data) = (title => '', meta => [],
style => [], script => []);
my($CURRENT);
my $p = new HTML::Parser (
start_h => [sub {
my($tagname, $attr) = @_;
$CURRENT = $tagname;
push(@{$data{meta}}, $attr) if ($tagname eq 'meta');
}, 'tagname, attr'],
text_h => [sub {
my($text) = @_;
if ($CURRENT eq 'title') {
$data{title} = $text;
}
elsif ($CURRENT eq 'style') {
push(@{$data{style}}, $text);
}
elsif ($CURRENT eq 'script') {
push(@{$data{script}}, $text);
}
}, 'dtext'],
end_h => [sub { $CURRENT = '' }]);
$p->parse_file(*DATA);