use File::Copy;
use File::Find;
use File::Path;
my $source = 'mysourcedir';
my $target = 'mytargetdir';
find( copy_files, $source );
# note: for the copy sub, $_ is set to the current file being tested, and we are chdir'd to the directory that file resides in.
sub copy_files {
my $targetdir = $File::Find::dir;
$targetdir =~ s/Q$source/Q$target/o;
mkpath( $targetdir ) if not -e $targetdir;
copy($_, "$target/$_") if -f;
}
use File::Find;
use File::Path;
my $source = 'mysourcedir';
my $target = 'mytargetdir';
find( copy_files, $source );
# note: for the copy sub, $_ is set to the current file being tested, and we are chdir'd to the directory that file resides in.
sub copy_files {
my $targetdir = $File::Find::dir;
$targetdir =~ s/Q$source/Q$target/o;
mkpath( $targetdir ) if not -e $targetdir;
copy($_, "$target/$_") if -f;
}