我想解压缩昨天的多个 log.gz 文件。
编码:
use strict;
use warnings;
use 5.010;
use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
use Time::Local;
#yesterday
my ($sec, $min, $hour, $mday, $mon, $year) = (gmtime())[0..5];
my $yesterday_midday=timelocal($sec,$min,$hour,$mday,$mon,$year) - 24*60*60;
($sec, $min, $hour, $mday, $mon, $year) = localtime($yesterday_midday);
my $path = sprintf "..\\..\\history\\%d\\%02d\\%02d\\*.log.gz",$year+1900, $mon+1, $mday;
print("PATH: $path\n");
gunzip '<path>' => '<#1.log>' #unzip all .log.gz files
or die "gunzip failed: $GunzipError\n";
错误:
Max wild is #0, you tried #1 at D:/Perl64/lib/IO/Uncompress/Base.pm line 545
您需要扩展标量$path
。在您的情况下,您告诉 gunzip 将名为path
通配符输出的文件解压缩。该错误告诉您字符串“path”不包含任何通配符,但您指的是匹配的通配符(由于“path”字符串中没有通配符,因此不存在)。
试试这个:
gunzip "<$path>" => '<#1.log>' #unzip all .log.gz files
or die "gunzip failed: $GunzipError\n";
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句