ALPM::Conf - pacman.conf config file parser and ALPM loader
use ALPM::Conf; my $conf = ALPM::Conf->new('/etc/pacman.conf'); my $alpm = $conf->parse; # Try again with custom fields: my $value; my %fields = ('CustomField' => sub { $value = shift }); $conf->custom_fields(%fields); $alpm = $conf->parse(); print "$value\n"; # When imported with an argument, a conf file is loaded and # an alpm instance (named $alpm) is imported into the caller's # namespace. use ALPM::Conf '/etc/pacman.conf'; print $alpm->get_arch, "\n"; # This is handy for the command line or shell scripts. % perl -MALPM::Conf=/etc/pacman.conf -e ' for $p ($alpm->localdb->pkgs){ print $p->name, " ", $p->version, "\n"; } '
This class is used to parse the pacman.conf files which are used by ArchLinux's pacman for config files. The configuration fields are used to set ALPM options. A new ALPM object instance is created with corresponding options set.
$OBJ = ALPM::Conf->new($CONF_PATH);
$CONF_PATH
The path to the configuration file that should be parsed.
$OBJ
A new ALPM::Conf object.
$ALPM_OBJ = $OBJ->parse()
Parses the configuration file that is located at the path provided by the constructor argument. Options and servers are applied to a newly created ALPM object.
$ALPM_OBJ
A new instance of an ALPM object.
undef = $OBJ->custom_fields(%CFIELDS);
%CFIELDS
A hash that describes custom fields and the actions that should be performed when a matching field is scanned. The keys of the hash are the field names (case sensitive) and the values are code references. When a field is scanned the code reference is called with the entire line of the field's value as the only argument.
When an import argument is given then special magic is performed. The argument should be the path to a pacman configuration file to load. This .conf file is parsed by a newly created ALPM::Conf instance. The result of the parsing is stored in the importing package's namespace under the name of the $alpm scalar. See the synopsis for an example. If you are not familiar, you can give import arguments the following ways:
$alpm
# Using use: use ALPM::Conf '/etc/pacman.conf'; # Require is more transparent: require ALPM::Conf; ALPM::Conf->import('/etc/pacman.conf'); # On the command-line (see perlrun(1) manpage): perl -MALPM::Conf=/etc/pacman.conf -e '...'
ALPM
Justin Davis, <juster at cpan dot org>
<juster at cpan dot org>
Copyright (C) 2015 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.
To install ALPM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ALPM
CPAN shell
perl -MCPAN -e shell install ALPM
For more information on module installation, please visit the detailed CPAN module installation guide.