#!/usr/bin/perl use strict; use Archive::Zip; use Archive::Zip::MemberRead; my ($zipfnm, $mbrfnm, @arglst) = @ARGV; { if (-e $zipfnm) { # ZIP file exists. Proceed. my $zipobj = Archive::Zip->new($zipfnm); # ZIP object pointer # Adjust Windows specifications my $mbranm = $mbrfnm; $mbranm =~ s/\\/\//g; # Proceed. my $mbrhan = Archive::Zip::MemberRead->new($zipobj, $mbranm); # Synopsis does not specify error handling return; # Left as an exercise for the reader :-) # OP indicates reading lines from the file, so use the text file technique while (defined(my $inpbuf = $mbrhan->getline())) { # Note the line read is already chopped or chomped (!!) print "Line " . $mbrhan->input_line_number . ": [$inpbuf]\n"; } } } exit; __END__ #### D:\PerlMonks>"C:\App\7-Zip\7z.exe" l -tzip test.zip 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Listing archive: test.zip -- Path = test.zip Type = zip Physical Size = 17540 Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 1995-03-03 22:42:08 ....A 24361 16886 binary.dat 2015-03-10 15:40:58 ....A 22 22 test.dat 2015-03-10 15:41:09 ....A 28 28 test2.dat 2015-04-23 19:41:25 ....A 82 62 test3.txt ------------------- ----- ------------ ------------ ------------------------ 24493 16998 4 files, 0 folders D:\PerlMonks>type test3.txt This is line one. This is line two. This is line four. The third was blank. D:\PerlMonks>zipreadfile1.pl test.zip test3.txt Line 1: [This is line one.] Line 2: [This is line two.] Line 3: [] Line 4: [This is line four. The third was blank.] Line 4: [] D:\PerlMonks>