본문 바로가기

카테고리 없음

hermian님의 2008-06-15 마가린 북마크입니다.


use File::Copy;
use File::Find;
use File::Path;

my $source = 'mysourcedir';
my $target = 'mytargetdir';

find( copy_files, $source );

# note: for the copy sub, $_ is set to the current file being tested, and we are chdir'd to the directory that file resides in.
sub copy_files {
my $targetdir = $File::Find::dir;
$targetdir =~ s/Q$source/Q$target/o;
mkpath( $targetdir ) if not -e $targetdir;
copy($_, "$target/$_") if -f;
}