#!/usr/local/bin/perl # # search for .report output files for experiments with TIDigits < 1.0 # $file_ext = '.report'; $pattern_string = "Percent Total Error"; # look in current directory $dir = "/cavs/hse/ies/d001/isip/data/exp/tidigits/"; chop($dir); &searchDirectory($dir); sub searchDirectory { local($dir); local(@lines_in_ls); local($line_in_ls); local(@lines_in_file); local($line_in_file); local($file); local($full_file_name); local($subdir); local($matched_patterns); $dir = $_[0]; # check for permission if(-x $dir) { # search this directory @lines_in_ls = `cd $dir; ls -l`; foreach $line_in_ls (@lines_in_ls) { $line_in_ls =~ /\s+(\S+)$/; $file = $1; if ($file =~ /$file_ext$/) { $full_file_name = $dir."/".$file; # print "$full_file_name\n"; open(INFO, $full_file_name); # Open the file @lines_in_file = ; # Read it into an array foreach $line_in_file (@lines_in_file) { if ($line_in_file =~ /$pattern_string\s*=\s(.*)\%/) { if ($1 < 1.0) { print "$full_file_name\n"; } last; } } close(INFO); } } } # search any sub directories @lines_in_ls = `cd $dir; ls -l`; foreach $line_in_ls (@lines_in_ls) { if($line_in_ls =~ /^d/) { # the 'd' is to do with ls -l expansion for directories $line_in_ls =~ /\s+(\S+)$/; $subdir = $dir."/".$1; &searchDirectory($subdir); } } }