use HTML::TokeParser::Simple 3.13; my %words; foreach my $url (@urls) { $words{$url} = 0; my $parser = HTML::TokeParser::Simple->new(url => $url); while (my $token = $parser->get_token) { next unless $token->is_text; # assumes you only search visible text $words{$url} += some_word_counting_function($token->as_is); } } # %words now has the count of words per url