tags:

views:

73

answers:

2

I need to copy all *.exe files in some directory to other virtual drive .

If I was writing batch script I would do xcopy "%mycopyposition%\*.exe".

But I think it will be a bad idea in Perl script .

I seen a File::Copy module, but couldn't see how to do that.

+3  A: 

Try this:

use File::Copy;
for my $file (<*.exe>) {
    # Copies from directory $mycopyposition to current directory.
    copy  "$mycopyposition/$file", $file or die "copy $file failed: $!";
}
Kinopiko
Note his `xcopy` copies *from* `%mycopyposition%` not to. And, while we are using modules, recommend using `File::Spec->catfile` to concatenate paths.
Sinan Ünür
Oh, sorry, I'm not familar with `xcopy`.
Kinopiko
thanks it already works for me
Night Walker
I'm glad to hear it.
Kinopiko
+3  A: 

I think it is an excellent idea to use xcopy. It does what you want. Plus, it preserves time stamps and other attributes. Has some very useful options.

Sinan Ünür