use HTML::SimpleLinkExtor; my $extor = HTML::SimpleLinkExtor->new(); $extor->parse_file($filename); # ---- or ----- $extor->parse($html); #extract all of the links @all_links = $extor->links;