#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; use WWW::Mechanize::TreeBuilder; my $mech = WWW::Mechanize->new(); WWW::Mechanize::TreeBuilder->meta->apply($mech); $mech->get('file:///home/example/path/index.html'); die "Cannot open file: ", $mech->response->status_line unless $mech->success; my @list = $mech->look_down(_tag => "a", class => "links); foreach (@list) { my $url = "file:///home/example/path/"; $url = $url . $_->attr("href"); print $_->as_text(), " - ", $url, "\n"; $mech->get($url); $mech->back(); }