#Created by Charles Oppenheimer, Recursive Technology LLC December 2004 #Distributed under Perl Artistic License. # set directory to be searched $dir='P:\sblprd1752\siebsrvr\log'; $comp_name = "SComm"; #matches file name.. losely $searchstring = "Error invoking Service";#string to match, must escape perl characters"; opendir(DIR, "$dir") || die "Could not open $dir $!"; while($name = readdir(DIR)) { ##Put the names in an array, latest files 1st if ($name =~ /$comp_name/) { print "puting name = $name in the array\n"; unshift(@files, $name); } } closedir(DIR); foreach (@files) { my $siebelfile = $_; #print "searching = $siebelfile\n"; open(SEARCHFILE, "<$dir/$siebelfile") || die "Could not open file $matchesboth : $!"; while () { #print "chomping file $dir, line = $line"; if ($_ =~ /$searchstring/) { print "matched string = $1 - file = $siebelfile - $string = $_\n"; } } }