Hi, I can't believe I'm having such a hard time with this. I just want a platform-independent way of copying a directory 'A' and its contents into another directory 'B' (as a subdirectory of B, named A). Not crossing filesystems or devices.
Various online sources have said you copy directories the same way you copy files; others have recommended File::Copy as a platform-independent copy/move command; and the File::Copy docs contain the following statement: "If the destination already exists and is a directory, and the source is not a directory, then the source file will be renamed into the directory specified by the destination." So what if the source *IS* a directory?? This is what I've tried. I've also tried 'move' rather than 'copy', and even appending '/' to the ends of the directory names. Thanks for a clue! #!/usr/bin/perl use warnings; use strict; use File::Copy; use File::Touch; use feature ":5.10"; my $f = "foo-dir"; my $b = "bar-dir"; my $fsub = "$f/subfoo-dir"; my $bsub = "$b/subbar-dir"; mkdir $f; mkdir $b; mkdir $fsub; mkdir $bsub; my $fsubsub_file = "$fsub/subsubfoo-file.txt"; touch $fsubsub_file; my $bsubsub_file = "$bsub/subsubbar-file.txt"; touch $bsubsub_file; # foo-dir/ # subfoo-dir/ ($fsub) # subsubfoo-file.txt # # bar-dir/ # subbar-dir/ ($bsub) # subsubbar-file.txt # # # Now - how can I copy subbar-dir/ and its contents into subfoo-dir/ as a subdirectory ?? # # I.E. I want this: # # foo-dir/ # subfoo-dir/ # subsubfoo-file.txt # subbar-dir/ # subsubbar-file.txt # say "copy $bsub, $fsub"; copy $bsub, $fsub or say "Copy directory->directory didn't work: $!"; # I've also tried move. Neither works. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/