my $calls_dir = "Bing/"; opendir( my $search_dir, $calls_dir ) or die "$!\n"; my @html_files = grep /\.html$/i, readdir $search_dir; closedir $search_dir; foreach my $html_files (@html_files) { my %seen = (); my $current_file = $calls_dir . $html_files; open my $FILE, '<', $current_file or die "$html_files: $!\n"; my $dom = Mojo::DOM->new( scalar slurp $calls_dir . $html_files ); print $calls_dir . $html_files; open my $fh, '>', "Bing/1Parsed/Html/${html_files}.result.txt" or die $!; for my $csshref ( $dom->find('a[href]')->attr('href')->each ) { my $cssurl = URI->new($csshref)->abs( $calls_dir . $html_files ); $fh->print("$html_files\n"); $fh->print("$cssurl\n"); } }