in reply to recursive dir and file
opendir only opens the directory for you, it does not change your current working directory. So you either need to do a chdir before doing any more tests on the files therein or prepend the directory name to the path.
Another possibility would be to use File::Find:
use File::Find; find (\&change_sas,"/cdw/home_dir/s006258/CSPAM"); sub change_sas { my $filename=$_; if (-f $filename && $filename=~m/\.sas\z/) { chmod 0644,$filename; print "Found $filename, changing\n"; } }
Or the *NIX find utility.
find /cdw/home_dir/s006258/CSPAM -name '*.sas' -exec chmod 644 {} \;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: recursive dir and file
by Aristotle (Chancellor) on Nov 13, 2005 at 00:05 UTC | |
by blazar (Canon) on Nov 14, 2005 at 09:28 UTC | |
by Aristotle (Chancellor) on Nov 14, 2005 at 09:35 UTC |