It's always safest(not sure if it's required) to give opendir an absolute directory name - that is, a directory name with a fully qualified path. Do the "element"s in /Scripts/rotlog have absolute directory names in them?
And, the $name that readdir returns is *NOT* an absolute filename. Therefore, before you try to test $name with a -M filetest operator, you must provide the absolute path to $name - something like this:
my $current_abs_dir = "/path/to/opendir/directory";
while ($name = readdir(REP)) {
$abs_name = "$current_abs_dir/$name";
if (-M $abs_name >= 10) {
If the elements in /Scripts/rotlog do not include the absolute path to the directory, you'll need to get the absolute path to the directory from somewhere.
Read the perldocs for opendir and readdir by doing
perldoc -f opendir
perldoc -f readdir
HTH. | [reply] [d/l] [select] |
Thanks, and yes the lines in /Scripts/rotlog are absolute paths. I want to read the contents of the dir in each line (path) of the /Scripts/rotlog file into the array. The issue is using the array elements instead of hard coding the paths.
| [reply] |
Add a $prepath = '/some/path/to/that/makes/elementfullyqual' right below the shabang, then rewrite the open and -d test with "$prepath$element"...
-Waswas
| [reply] [d/l] [select] |
Thanks, but that made matters worse. The contents of the 'rotlog" file are fully qualified directory paths. Any other ideas?
| [reply] |