2017-03-01 1874 views
0

我想从昨天解压缩多个log.gz文件。解压缩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 

回答

-1

您需要扩展标$path就你而言,你正在告诉gunzip将一个名为path的文件解压缩为野生普通输出。该错误告诉你,字符串“路径”不包含任何通配符,但是您指的是匹配通配符(由于“路径”字符串中没有通配符,因此不存在)。

试试这个:

gunzip "<$path>" => '<#1.log>' #unzip all .log.gz files 
     or die "gunzip failed: $GunzipError\n"; 
+0

改变了它,但误差保持不变。 –

+0

更改为“,”谢谢! –

+0

是的,我的坏,编辑。单引号不会内插变量,它将采取字符串,因为它是字面上。 –