【发布时间】:2015-08-27 22:31:37
【问题描述】:
我正在尝试从目录压缩文件。它工作得很好,除非文件名有空格。
由于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);
【问题讨论】:
标签: perl activestate