in reply to Copying files between directories. How can I improve this code.

there is a bug that nobody has commented before here ...
while ($name = readdir(ORIG)){
A file named 0 (= number zero, that is unlikely, but not impossible) would cause the loop to end.

You have to check if the value is defined instead:

while (defined($name = readdir(ORIG))){
Though, the best solution is to use readdir in list context replacing the full while loop:
my @Filenames = readdir ORIG;

Replies are listed 'Best First'.
Re^2: Copying files between directories. How can I improve this code.
by jwkrahn (Abbot) on Apr 23, 2006 at 01:34 UTC
    Modern versions of Perl aready provide this:
    $ perl -MO=Deparse -e'while ($name = readdir(ORIG)) {}' while (defined($name = readdir ORIG)) { (); } -e syntax OK