in reply to How to use File::Find for EAR

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

Replies are listed 'Best First'.
Re^2: How to use File::Find for EAR
by Anonymous Monk on Nov 30, 2007 at 07:49 UTC
    Hi great monks
    What a beautifull solution thanks a lot
    is this solution appilicable for JAR files