- 論壇徽章:
- 0
|
使用File::Find和File::Copy 把一個(gè)文件夾及子文件夾里的.pl文件復(fù)制到另外一個(gè)文件夾,路徑體現(xiàn)在目標(biāo)文件的文件名中。使用下邊的程序,只把當(dāng)前目錄里的.pl文件復(fù)制過去了,文件夾里的文件都沒有復(fù)制過去,這個(gè)是啥問題?感覺copy的參數(shù)沒有問題。- #!perl.exe
- use File::Find;
- use File::Copy;
- my $dest_dir = "D:/new/";
- find(\&wanted, '.');
- sub wanted{
- unless (-d){
- my $name = $File::Find::name;
- my $origin = $name;
- next unless $name =~ /.*\.pl$/;
- $name =~ s/^\.\///;
- $name =~ s/\//_/;
- $name = $dest_dir . $name;
- print "Origin: $origin \n";
- print "Copy to $name \n";
- print "result: ", copy($origin, $name) , "\n";
- }
- }
復(fù)制代碼 結(jié)果是這樣的,子文件夾的都復(fù)制失敗了。是哪里出問題了呢?- Origin: ./pakage.pl
- Copy to D:/new/pakage.pl
- result: 1
- Origin: ./webfetion.pl
- Copy to D:/new/webfetion.pl
- result: 1
- Origin: ./wingui.pl
- Copy to D:/new/wingui.pl
- result: 1
- Origin: ./gd/GDEx.pl
- Copy to D:/new/gd_GDEx.pl
- result:
- Origin: ./intermidiatperl/c11-2.pl
- Copy to D:/new/intermidiatperl_c11-2.pl
- result:
- Origin: ./intermidiatperl/c11.pl
- Copy to D:/new/intermidiatperl_c11.pl
- result:
- Origin: ./intermidiatperl/c12.pl
- Copy to D:/new/intermidiatperl_c12.pl
- result:
- Origin: ./intermidiatperl/c14e1.pl
- Copy to D:/new/intermidiatperl_c14e1.pl
- result:
復(fù)制代碼 |
|