Hello Coroner, and welcome to the Monastery!
Within the loop foreach (@list_FTP), the statement:
my $zip = Archive::Zip->new($_);
creates a new Archive::Zip object and initialises it with the contents of the zip file named by $_. The object now contains one member. Then, in the conditional:
if ($zip->read($_) == AZ_OK)
the contents of that same zip file are again added to the archive object, which now contains two members!
One solution is to create an empty object and populate it only via the read method:
for (@list_FTP) { $logger->info("Trying to Unzip : $_"); #initialising zip file my $zip = Archive::Zip->new(); # <-- create empty archive if ($zip->read($_) == AZ_OK) { ...
BTW, it’s better practice to pass a variable such as @list_FTP as an argument to the subroutine.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Archive::Zip members print twice
by Athanasius
in thread Archive::Zip::Members print twice
by Coroner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |