John Deretich wrote:
Hello,
can anyone tell me how to do a complete copy of files and directories from one directory to another? I tried system('copy g:\*.* F:\test\test2') with no success.
use File::Copy; use strict;
sub copydir {
my ($dir, $to) = @_; print "copydir: $dir\n";
opendir IN, $dir or die "what is this: $dir";
my @list = readdir IN;
closedir IN; if (! -d $to) {
mkdir $to, 0777;
}
foreach my $i (@list) {
my $file = "$dir/$i"; if ( -d "$file") {
if (( $i ne ".") && ( $i ne "..")) {
©dir( "$file", "$to/$i");
}
} elsif (-f "$file") {
copy("$file","$to/$i");
} else {
print "Hey, whats this?? $file\n";
}
}
}copydir( "C:/etc", "H:/tmp/urgs");
thanks,
John
HTH
Alex
-- _________________________________creating IT solutions Alexander Apprich science + computing ag IT-Services Hagellocher Weg 71-75 phone +49(0)7071 9457-291 D-72070 Tuebingen, Germany fax +49(0)7071 9457-211 www.science-computing.de
_______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
