StormMedic85
Programmer
Within an array of files, I'd like to search for files with a specific pattern. All the files follow a standard format (for example, abc123.YEAR.MONTH.DAY.abc.TIME). I'm trying to use grep but I think my implementation may be incorrect. Here's an example of how I'm trying to do things. Perhaps it'll be easy to see where I'm going wrong. Thanks!
$dirname = "/directory";
opendir(FH, $dirname);
while (defined($file = readdir(FH))) {
@filearray = "$dirname/$file";
}
@filematch = grep(/abc123.$year$month$day.abc.$time/, @filearray);
print "The matched files are @filematch";
$dirname = "/directory";
opendir(FH, $dirname);
while (defined($file = readdir(FH))) {
@filearray = "$dirname/$file";
}
@filematch = grep(/abc123.$year$month$day.abc.$time/, @filearray);
print "The matched files are @filematch";