Just a nit-pick: this use of $/ seems inappropriate:
in reply to Is there a Limit on Matching .*
considering that you don't seem to expect the close tag to always be lower case... I presume you had a reason for including the "i" flag on this regex:
$/ = '</h1>';
And of course, the value of $/ cannot be treated as a regex -- it has to be a literal string.
$chunk =~ m%<h1>(.+)</h1>%i;
Actually, given that you can "guarantee" only one "h1" tag in an html file, if it happens to be capitalized, you'll just slurp the whole file into $chunk, and the remaining logic will work in any case. But don't fall into a false sense of safety about this sort of usage -- it'll trip you someday.