Re: Using Perl to Read jar file MANIFEST file.
[email protected] (Claes Jakobsson)
| Newsgroups | perl.macosx |
|---|---|
| Message-ID | <[email protected]> |
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use Archive::Zip::MemberRead;
my $archive = Archive::Zip->new();
die "read error" if $archive->read(shift) != AZ_OK;
my $fh = Archive::Zip::MemberRead->new($archive, "META-INF/
MANIFEST.MF");
while (defined($_ = $fh->getline())) {
print "$_\n";
}
galaxy:~ claes$ perl jar_reader.pl /usr/share/java/junit.jar
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
seems to work
/Claes
On 5 mar 2008, at 19.40, Claes Jakobsson wrote:
> On 5 mar 2008, at 19.23, Michael Barto wrote:
>> Has anybody every tried to create a Perl program ro read the
>> contents of the MANIFEST file in java jar file? We are trying to
>> develop something to provide comparisons for change between
>> different implementations. Is this a simple Perl backtic, system or
>> exec of the jar command or is there a more exotic way to do it?
>> Also, we need to extract Checksum. But that seems documented.
>
> If I remember correctly JAR files are simply Zip files so you should
> be able to use something like Archive::Zip to read the file.
>
> Cheers
> Claes