# Assumes filenames of the form *yyyymmdd.txt my $filepattern = sprintf("*%d%d%d.txt", 1900+(localtime)[5], 1+(localtime)[4], (localtime)[3]); foreach my $filename (glob($filepattern)) { # Process individual files herein } #### # Looking, for instance, for "/usr/.*/?bin/perl" my $regex = qr{(/usr/.*/?bin/perl)}gs; my ($line); { open(DF, $filename) or die("Can't open $filename for input: $!\n"); my @lines = ; close(DF); $line = join('', @lines); } my @matches = $line =~ m/$regex/; printf "Filename: %40s Occurrances: %9d\n", $filename, scalar @matches;