You can use File::Find to locate files whose filename indicate that they are of the type you want, then use Archive::Zip to inspect those files:
use strict; use warnings; use Data::Dumper; use File::Find; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $dir = q{/opt/ibm/db2/V9.5/samples/}; my @files = (); find( sub { return unless -f; # skip non-files push @files, $File::Find::name if m/.*(war|ear)$/i; }, $dir ); foreach my $file (@files) { my $zip = Archive::Zip->new(); if ($zip->read($file) == AZ_OK) { my @members = $zip->memberNames(); print qq{$file has } . scalar(@members) . q{ member(s)}; } else { die "failed to open $file"; } } __END__
$ perl -l 653779.pl /opt/ibm/db2/V9.5/samples/java/Websphere/OptimisticLocking.war has 76 +member(s) /opt/ibm/db2/V9.5/samples/java/Websphere/AccessEmployee.ear has 10 mem +ber(s) /opt/ibm/db2/V9.5/samples/repl/asnqwxml/stockticker/dist/stockticker.w +ar has 15 member(s)
--
Andreas

In reply to Re: How to use File::Find for EAR by andreas1234567
in thread How to use File::Find for EAR by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.