"gusmeister" <gu****************@sympatico.ca> wrote in message news:<4o******************@news20.bellglobal.com>. ..
Is there a Perl mod that has a recursive file copy function (similar to
`cp -r` in Unix or `xcopy` in Windows)? File::Path does have a recursive
file deletion function (rmtree) but no recursive copy function (e.g.
cptree).
You could combine File::Find which recursively descends directories
and File::Copy which copies files. I can't be sure the following code
will work without knowing a bit more about how you want the
destination to look, but it might go something like this:
use File::Find;
use File::Copy;
sub visit {
my $file = $File::Find::name;
my $base = $file;
$base =~ s!/base/path/to/remove/!!;
copy($file, "/new/path/$base");
}
find({ wanted => \&visit, no_chdir => 1 }, '/base/path/to/remove');