/usr/share/perl5/Parse/Debian/Packages.pm is in libparse-debian-packages-perl 0.03-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | use strict;
package Parse::Debian::Packages;
our $VERSION = '0.03';
sub new {
my $class = shift;
my $fh = shift;
return bless { fh => $fh }, $class;
}
sub next {
my $self = shift;
my $fh = $self->{fh};
my %parsed;
my $lastkey;
while (<$fh>) {
last if /^$/;
if (my ($key, $value) = m/^(\S+): (.*)/) {
$parsed{$key} = $value;
$lastkey=$key;
}
else {
s/ //;
s/^\.$//;
chomp;
$parsed{$lastkey} .= "\n" . $_;
}
}
return %parsed;
}
sub as_hash {
my $class = shift;
my $parser = $class->new(@_);
my %hash;
while (my %package = $parser->next) {
$hash{ $package{Package} } = \%package;
}
return \%hash;
}
1;
=head1 NAME
Parse::Debian::Packages - parse the data from a debian Packages.gz
=head1 SYNOPSIS
use YAML;
use IO::File;
use Parse::Debian::Packages;
my $fh = IO::File->new("Packages");
my $parser = Parse::Debian::Packages->new( $fh );
while (my %package = $parser->next) {
print Dump \%package;
}
=head1 DESCRIPTION
This module parses the Packages files used by the debian package
management tools.
It presents itself as an iterator. Each call of the ->next method
will return the next package found in the file.
For laziness, we take a filehandle in to the constructor. Please open
the file for us.
=head1 METHODS
=head2 new( $filehandle )
=head2 next
Iterate to the next package in the file, returns either a hash
containing a package description, or false at end of file.
=head2 as_hash( $filehandle )
Return all the packages from a filehandle as a hash of hashes.
=head1 AUTHOR
Richard Clamp <richardc@unixbeard.net> with as_hash implementation by
Thomas Klausner.
=head1 COPYRIGHT
Copyright (C) 2003,2005,2012 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 SEE ALSO
Module::Packaged
=cut
|