If you just want a list of the files in a directory then it's easier to just use glob
Also note that the files in a directory are not ordered, so any list will be in a random order unless you sort it.
Your code could then look something like this :-
use File::Basename; my @files = glob('/path/to/files/*'); foreach my $file (@files) { my $name = basename($file); if (! -x "/new_path/$name") { # copy file here } }
Have a look at the help for File::Basename or better yet File::Spec for functions to safely handle paths & filenames
In reply to Re^7: dir handle
by RichardK
in thread dir handle
by Mjpaddy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |