NAME
ALPM::Package - ALPM package class.
SYNOPSIS
use ALPM qw( /etc/pacman.conf );
my $perlpkg = ALPM->localdb->find('perl');
# TMTOWTDI!
my $name = $perlpkg->name();
print "$name rocks!\n";
my %attrs = $perlpkg->attribs();
print "$attrs{name} rocks!\n";
my $attrs_ref = $perlpkg->attribs_ref();
print "attrs_ref->{name} rocks!\n";
# Dependencies are given as arrayrefs of hashrefs (AoH):
print "$name depends on:\n";
for my $dep ( @{ $perlpkg->depends() } ) {
my @words = @{$dep}{'name', 'mod', 'ver'};
print " @words\n";
}
# Others lists are arrayrefs of scalars:
print "$name owns files:\n";
print " $_\n" foreach ( @{ $perlpkg->files } );
DESCRIPTION
This class is a wrapper for all of the alpm_pkg_...
C library functions of libalpm. You retrieve the package from the database and you can then access its attributes. Attributes are like ALPM's options. There are many different ways to access them. You cannot modify a package.
ATTRIBUTES
There are three basic ways to access an attribute. You can use the accessor method that is specific to an attribute, you can use the attr
method, or you can use the attribs
method.
Attribute Accessors
The accessors are named (almost) exactly the same as the alpm_pkg_get...
functions. They are easy to use if you only want a few attributes.
I have removed the get_ prefix on the accessors. This is because you can't really set anything so you should know it's a get anyways.
filename
name
version
desc
url
builddate
installdate
packager
md5sum
arch
size
isize
reason
licenses
groups
depends
optdepends
conflicts
provides
deltas
replaces
files
backup
has_scriptlet
download_size
changelog
requiredby
Attributes with plural names return an arrayref of strings.
Dependency Lists
depends is different because it returns an arrayref of hashrefs (an AoH). The hash has the following key-value pairs:
|---------+----------------------------------------|
| Key | Value |
|---------+----------------------------------------|
| name | Package name of the dependency |
| version | The version to compare the real one to |
| mod | The modifier of the dependency |
| | ('==', '>=', '<=', '<', or '>') |
|---------+----------------------------------------|
PERLISH METHODS
There are also more ways to get attributes. attribs
is useful if you want to get all attributes at once in a hash, or many attributes at once into a list or variables.
attribs
Usage : my %attribs = $pkg->attribs();
my ($name, $desc) = $pkg->attribs('name', 'desc');
Params : If you specify attribute names, their values are returned as
a list. Otherwise, returns a hash of all attributes.
Returns : Either a hash or a list.
attribs_ref
This is the same as attribs, but it returns a hashref or
arrayref instead.
SEE ALSO
AUTHOR
Justin Davis, <juster at cpan dot org>
COPYRIGHT AND LICENSE
Copyright (C) 2011 by Justin Davis
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.