我尝试使用Perl将当前文件夹和子文件夹中的所有.config文件复制到新位置。
我尝试的代码:
use strict;
use warnings;
my $pwd = "/home/radar/sample";
my $destination = "/home/radar/proj";
opendir(DIR, "$pwd") or die "Error";
my @files = readdir(DIR);
closedir(DIR);
foreach my $file ( @files ) {
next if ($file !~ /\.config$/i); # filtered only file with extension .config
system(`cp \"$pwd\\$file\" \"$destination\"`);
}
错误:
cp:无法统计'/home/radar/sample\project_status.config'