我正在尝试从目录中压缩文件。它工作得很好,除非文件名有空格。
由于glob
将其参数拆分为空格,因此我也尝试过bsd_glob
,但没有成功。
如何处理文件名中的空格?我正在寻求检索所有文件。
#Directory of focus
my $log = 'C:/Users/me/Desktop/log';
my @files = bsd_glob( $log.'/*.*' );
#Copy contents to new directory to be zipped
foreach my $file (@files) {
copy($file, $logout) or die
"Failed to copy $file: $!\n";
}
复制失败
# Create Child tmp
my $out = 'C:/Users/me/Desktop/out';
mkdir $out;
# Directory of focus
my $log = 'C:/Users/me/Desktop/log';
opendir (DIR, $log) or die $!;
while ( my $file = readdir(DIR) ) {
next if $file =~ /^\./;
#print "$file\n";
copy($file, $out) or die "Failed to copy $file: $!\n";
}
closedir (DIR);