I need to check for the existence of a file in a directory. The file name has a pattern like:
/d1/d2/d3/abcd_12345_67890.dat
In my program, I will know the file name up to abcd_
I need to write an if
condition using -e
option and find the files matching above given pattern.
You can use glob to return a list of existing files whose name matches a pattern:
my @files = glob '/d1/d2/d3/abcd_*.dat';
In this case, there is no need to perform the -e
filetest.