我在Mac 10.5.7上使用Perl 5.12.我有一个JAR文件,我希望解压缩,然后处理匹配文件模式的文件.我无法弄清楚如何迭代解压缩的结果.我有 ...
### build an Archive::Extract object ###
my $ae = Archive::Extract->new( archive => $dbJar );
### what if something went wrong?
my $ok = $ae->extract or die $ae->error;
### files from the archive ###
my @files = $ae->files;
for (@files) {
print "file : $_\n";
Run Code Online (Sandbox Code Playgroud)
但是循环中只返回了一个东西 - "ARRAY(0x7fd5c22f7cd8)".我知道存档中有很多文件,所以我很好奇我在这里做错了什么. - 戴夫
小智 6
$ae->files返回数组引用,而不是数组.试试这个:
my $files = $ae->files;
for(@$files) {
print "file : $_\n";
}
Run Code Online (Sandbox Code Playgroud)