use HTML::Parser;
use LWP::Simple qw(get);
my $url = 'http://www.perlmonks.org/';
my @links;
my $parser = new HTML::Parser( # make a new parser
api_version => 3,
start_h => [ sub { push @links, pop @{$_[0]} }, 'tokens' ], # stack the url part of the anchor tag to @links
);
$parser->report_tags("a"); # only handle a tags
$parser->parse(get($url)); # parse perlmonks.org
print join("\n",@links); # print all links from the root page