in reply to Move multiple files?

Since no shell interpolation is performed on the filename, the filesystem is queried for an actual file called '*'. You may be interested in peerforming a chdir($curSubmitDir); @filesFrom = glob("*");, which will use the shell to get the list of files, and store them in an array. Then you have to copy the files one by one:
foreach my $fileFrom (@filesFrom){ move ($fileFrom, $fileTo) or die "$!"; }


You may also use a different approach - which is a bit more efficient, and secure:
opendir SUBM, $curSubmitDir; while (defined (my $fileFrom = readdir DIR)){ move ($fileFrom, $fileTo) or die "$!"; }
Which will open the directory, and read it item by item, instead of performing a glob. This will also avoid an array in memory, and will not change your working directory.

-nuffin
zz zZ Z Z #!perl

Replies are listed 'Best First'.
Re: Re: Move multiple files?
by kelan (Deacon) on Oct 28, 2002 at 21:48 UTC
    Another benefit of the second approach is that it will also copy files with leading dots, which globbing will not do.

    kelan


    Perl6 Grammar Student