Hi,
Use File::Copy::Recursive:
NAME
File::Copy::Recursive - Perl extension for recursively copying files and
directories
SYNOPSIS
use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);
fcopy($orig,$new[,$buf]) or die $!;
rcopy($orig,$new[,$buf]) or die $!;
dircopy($orig,$new[,$buf]) or die $!;
fmove($orig,$new[,$buf]) or die $!;
rmove($orig,$new[,$buf]) or die $!;
dirmove($orig,$new[,$buf]) or die $!;
rcopy_glob("orig/stuff-*", $trg [, $buf]) or die $!;
rmove_glob("orig/stuff-*", $trg [,$buf]) or die $!;
DESCRIPTION
This module copies and moves directories recursively (or single files,
well... singley) to an optional depth and attempts to preserve each file
or directory's mode.
Octavian
----- Original Message -----
From: "Swayam" <swaya...@gmail.com>
To: <beginners@perl.org>
Sent: Thursday, March 05, 2009 4:44 PM
Subject: Copy file recursively
Hi ,
My directory structure is like
ls -R temp
temp:
2.1 2.2 cleanup setup
temp/2.1:
2.1.1 cleanup setup
temp/2.1/2.1.1:
setup cleanup 2.1.1.01 2.1.1.02 2.1.1.03 2.1.1.04 2.1.1.05 2.1.1.06
2.1.1.07 2.1.1.08
temp/2.1/2.1.1/2.1.1.01:
cleanup setup test
temp/2.1/2.1.1/2.1.1.02:
cleanup setup test
temp/2.1/2.1.1/2.1.1.03:
cleanup setup test
temp/2.1/2.1.1/2.1.1.04:
cleanup setup test
temp/2.1/2.1.1/2.1.1.05:
cleanup setup test
temp/2.1/2.1.1/2.1.1.06:
cleanup setup test
temp/2.1/2.1.1/2.1.1.07:
cleanup setup test
temp/2.1/2.1.1/2.1.1.08:
cleanup setup test
temp/2.2:
2.2.1 cleanup setup
temp/2.2/2.2.1:
2.2.1.01 2.2.1.02 2.2.1.03 2.2.1.04 2.2.1.05 2.2.1.06 2.2..1.07
2.2.1.08 2.2.1.09 2.2.1.10
temp/2.2/2.2.1/2.2.1.01:
test
temp/2.2/2.2.1/2.2.1.02:
setup test
temp/2.2/2.2.1/2.2.1.03:
setup test
temp/2.2/2.2.1/2.2.1.04:
setup test
temp/2.2/2.2.1/2.2.1.05:
test
temp/2.2/2.2.1/2.2.1.06:
setup test
temp/2.2/2.2.1/2.2.1.07:
setup test
temp/2.2/2.2.1/2.2.1.08:
setup test
temp/2.2/2.2.1/2.2.1.09:
setup test
temp/2.2/2.2.1/2.2.1.10:
setup test
I want to copy some subdirectory and files under it to another directory
it
should exactly create similar directory structure
like if i will give temp
/2.2/2.2.1/2.2.1.10:
/2.2/2.2.1/2.2.1.08:
and
then it will create a directory destination/
ls -R destination
destination:
2.2 cleanup setup
destination/2.2:
2.2.1 cleanup setup
destination/2.2/2.2.1/2.2.1.10:
setup test
destination/2.2/2.2.1/2.2.1.08:
setup test
means exact directory tree will all files
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/