There are a few things wrong with your code. It doesn't use warnings
or strict. It has inconsistent indentation. It is trying to parse
HTML with simple regular expressions. You could do worse than using
something already built for such a purpose like HTML::LinkExtor or
HTML::SimpleLinkExtor.