如何複製檔案及目錄
use File::Copy;
copy('file1.txt','file2.txt') or die "can't copy: $!\n";
複製目錄
sub copy_dir{
my $source = $_[0];
my $target = $_[1];
use File::Copy;
opendir(DIR,$source);
while(my $filename = readdir(DIR)){
if(-f "$source/$filename")){
copy("$source/$filename","$target/$filename") or die "can't copy: $!\n";
}
}
close(DIR);
}
參考網頁
您可能會對以下這些文章感興趣
2005
6
1月
- Posted by citypig at 12:27 am (824 views)
- Permalink for this entry
- Filed under: perl
- RSS comments feed of this entry
- TrackBack URI










沒有任何留言
發表您的評論