#! /usr/bin/perl use strict; use warnings; use HTML::Parser; my @links; my $file = "my_file.html"; my $p = HTML::Parser->new(); $p->handler(start => \&start_handler,"tagname,attr,self"); $p->parse_file($file); foreach my $link(@links){  print "Linktext: ",$link->[1],"\tURL: ",$link->[0],"\n"; } sub start_handler{  return if(shift ne 'a');  my ($class) = shift->{href};  my $self = shift;  my $text;  $self->handler(text => sub{$text = shift;},"dtext");  $self->handler(end => sub{push(@links,[$class,$text]) if(shift eq 'a')},"tagname"); }