# Take each word from the array of search words and apply the qr// operator to prevent a recompile for each regex. # Output the words to a new array using map (faster than foreach). @search_array = map { qr/\b$_\b/i } @and_array; # For each file within the directory while ( defined( $File = readdir(DIR) ) ) { # Skip the directory and parent directory (read as . and ..) next if $File =~ /^\.\.?$/; # Open the file for regular expression match open ( FILE, "$File" ) || die "Cannot open file $File: $!"; # Read file into an array @file_contents = (); @file_contents = ; close FILE; $nomatch = "0"; # Loop to match each search word held in the array against each line in the file. WORD: for $word ( @search_array ) { @found = (); @found = grep /$word/i, @file_contents; if ( scalar @found == 0 ) { $nomatch = "1"; last WORD; } } if ( $nomatch == "0" ) { $x = $x + 1; print LIST "$x $File ".$TelonDir.$in{'scope'}."\\$File \n"; } # End of while defined $File closedir DIR; close LIST;