#!/usr/local/bin/perl # # specifying that teh file should end with .html # $file_extension = '.html'; # There are the 2 strings & atleast 1 number to search # @strings_needed = ('and', 'speech','[0-9]+'); # Going to the directory that points to our website # $diectory_main = "/cavs/hse/ies/www/"; chop($directory_main); # every file in the directory is searched for the strings # if the file has .html extension # &search4match($directory_main); # search this directory # @lines = `cd $directory; ls -l`; foreach $line (@lines) { $line =~ /\s+(\S+)$/; $file = $1; # if the file has .html extension if ($file =~ /$file_extension$/) { $full_file_name = $directory."/".$file; open(INFO, $full_file_name); # open the file @lines_in_file = ; # read into an array $matched_patterns = 0; # intialise the number of patterns matched to 0 foreach $pattern_string (@strings_needed) { foreach $line_in_file (@lines_in_file) { if ($line_in_file =~ /$pattern_string/) { $matched_patterns += 1; last; } } close(INFO); if ($matched_patterns>= 3) { print "$full_file_name\n"; } } } # search any sub directories @lines = `cd $directory; ls -l`; foreach $line (@lines) { if($line = ~ /^d/) { @line_in_ls =~ /\s+(\S+)$/; $subdir = $directory."/".$1; &search4match($subdir); } } } }