in reply to Reading zipped files (.gz)

You include Archive::Tar in your code and your @cdr_list array is meant to be populated with a list of (gzipped) tars, but your dump of the variable doesn't match your command since none of those files is a tar. So, assuming the mention of tar is an artifact and you really just need to deal with zipped files:

use IO::Zlib; my $fh = new IO::Zlib; $fh->open('zipfile.gz','rb'); while(<$fh>) { print } $fh->close

If/when you decide to deal with gzipped tars, Archive::Tar can open gzipped files automatically without needing to explicitly unzip them.

chomp @cdr_list; foreach my $tarzip (@cdr_list) { my $tar = Archive::Tar->new($tarzip); foreach my $file ($tar->list_files) { print $tar->get_content($file) } }
Dum Spiro Spero

Replies are listed 'Best First'.
Re^2: Reading zipped files (.gz)
by Corion (Patriarch) on Nov 18, 2015 at 15:43 UTC