use LWP; my $browser = LWP::UserAgent->new(); my $index = 0; my $response = $browser->get($url_name); foreach (@links) { $response = $browser->get($_); if (($response->content_type eq 'text/html') || ($response->content_type eq 'text/plain')) { $index++; } else { splice(@links, $index, 1); } } foreach (@links) { print "$_\n"; }