#!/usr/bin/env perl use strict; use warnings; my $filename = '/home/someuser/foo.zip'; my $read = `unzip -l $filename`; # Read in the output of the unzip -l command. chomp(my @contents = split /\n/, $read); # Note: # $contents[0] contains the archive name. # $contents[1] contains the header. # $contents[2] contains a header delimiter ------. # $contents[3] contains the first file listing. # ..... # $contents[-3] contains last file listing. # $contents[-2] contains a footer delimiter ------. # $contents[-1] contains a summary. my $pos = index $contents[1], 'Name'; # Find the 'Name' field. The start of that field is # the position in subsequent lines where filenames # begin. my $n = 1; # Keep track of row number, just because. foreach my $item (@contents[3 .. $#contents - 2]) { # Start with the first file entry, and end with the last file entry. my $filename = substr($item, $pos); # Use our index position to look for a substring starting where # the Name field began. print $n++, ": $filename\n"; # Print out output. } #### Archive: /home/davido/Downloads/dash-to-dock@micxgx.gmail.com.v61.shell-extension.zip Length Date Time Name --------- ---------- ----- ---- 0 2017-09-06 14:09 locale/zh_CN/LC_MESSAGES/ 2754 2017-09-06 14:09 stylesheet.css 8981 2017-09-06 14:09 locale/es/LC_MESSAGES/dashtodock.mo ...(and so on...) 635 2017-12-23 17:29 metadata.json --------- ------- 659482 82 files