This line seems problematic:
use strict;
Most of the web is messy. Beautiful Soup and its ilk would seem like a better choice for parsing.