[pm-h] Recursive Directory Copy

Mike Flannigan mikeflan at att.net
Sat Jun 7 19:54:26 PDT 2008


Mike Flannigan wrote:
> Do you guys know what is wrong here.  I'm trying to
> copy a directory recursively.  I thought some combination
> of these commands might work, but all give various errors
> like "Invalid Argument".
>
> This is on Win32.
>
>
> use strict;
> use warnings;
> use File::NCopy qw(copy);
>
> my $dir1 = "C:/Lame";
>
> my $dir2 = "C:/Copy2";
>
> copy \1,"$dir1","$dir2" or die "Copy failed: $!";
> #copy "$dir1","$dir2" or die "Copy failed: $!";
> #copy $dir1,$dir2 or die "Copy failed: $!";
>
>
> #my $file = File::NCopy->new(recursive => 1);
> #my $file = File::NCopy->new(u_chmod => \&my_chmod,f_check => \&my_fcheck);
> #$file->copy "$dir1","$dir2"  or die "Copy failed: $!";
>
>
> __END__
>
>   

Never mind.  I finally found one that works:

use strict;
use warnings;
use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);

my $dir1 = "C:/Lame";

my $dir2 = "C:/Copy2";

dircopy($dir1,$dir2) or die "Copy failed: $!";

__END__


This was much harder than it should be.


Mike



More information about the Houston mailing list