aufrank and all responders;
Thank you for the explaination and suggestions on asking questions. All of these responses will be of some help, even the oneliner. Although I understand the concepts of opening and reading from file, understanding how the array is created, and actually substuting the elements into my code is vague to me. I have included my code so that my question is more explicit.
I am trying to delete the files in the reports directory that are x days old. I have 67 directories under /opt/web that all have reports directories. I would like to place all of these paths into a text file to be read into the array, and have the following actions performed.
# open the directory for reading
chdir "/opt/web/hr83tst/reports";
opendir(REP, "/opt/web/hr83tst/reports") || die "Cannot open the dire
+ctory /opt/web/hr83/reports $! ";
open(remlog,">/Scripts/dir-removed.log"); # open a file to keep as a
+log of directories removed.
print remlog "Directories removed this date : ",`date`, "\n";
# list the contents of the directory. These should be directories.
while ($name = readdir(REP)) {
if (-M $name >= 10) {
print "$name\n" unless($name eq "images");
print remlog "$name\n" unless($name eq "images");
`rm -r $name` unless($name eq "images"); # THIS WILL REMOVE THE D
+IRECTORY AND ALL OF ITS subdirectories and Files.
}
}
close remlog;
closedir(REP)