Copying directories.
Guys, I thought this woule be a lot easier than it seems... All I want to do is to copy a directory, and everything it contains (whatever this may be) to a new directory. I (finally) managed it with a system command: if (system xcopy /E/I/C \$default_path\ \$new_path\) {print Copy failed\n$!\n;die}; but it's _really_ horrible, and not portable. What's the nice and easy way to do this? Thanks. R. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Copying directories.
Found this bit of code on the web recently... sub copydir { my ($dir, $to) = @_; print "copying $dir to $to\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 "..")) { copydir( "$file", "$to/$i"); } } elsif (-f "$file") { copy("$file","$to/$i"); } else { print "Hey, whats this?? $file\n"; } }} Beckett Richard-qswi266 [EMAIL PROTECTED] wrote: Guys,I thought this woule be a lot easier than it seems...All I want to do is to copy a directory, and everything it contains(whatever this may be) to a new directory.I (finally) managed it with a system command:if (system "xcopy /E/I/C \"$default_path\" \"$new_path\"") {print "Copyfailed\n$!\n";die};but it's _really_ horrible, and not portable.What's the nice and easy way to do this?Thanks.R.___Perl-Win32-Users mailing list[EMAIL PROTECTED]To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
Re: Copying directories.
At 11:08 2004-01-13, Beckett Richard-qswi266 wrote: I thought this woule be a lot easier than it seems... All I want to do is to copy a directory, and everything it contains (whatever this may be) to a new directory. -snip- What's the nice and easy way to do this? The CPAN way of course ;) http://search.cpan.org/~mzsanford/File-NCopy-0.34/ /J -- --- -- -- -- -- - - - Johan Lindström Sourcerer @ Boss Casinos [EMAIL PROTECTED] Latest bookmark: The New Yorker Fact http://www.newyorker.com/fact/content/?040112fa_fact dmoz (1 of 24): /Arts/Literature/Authors/K/ 326 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs