XML::LibXML example. Terse and robust. Don't reach for regexes for HTML unless it's an instant one-off you'll be able to verify by eye. Parsers require little more effort and are much more reliable.
use strict;
use warnings;
use XML::LibXML;
my $parser = XML::LibXML->new();
$parser->keep_blanks(1);
$parser->recover_silently(1);
# There are other parse methods: string, fh.
my $dom = $parser->parse_html_file(shift || die "give a file\n");
$_->setAttribute("href", "#") for $dom->findnodes('//a[@href]');
print $dom->serialize(1);