The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#
# (c) Jan Gehring <jan.gehring@gmail.com>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:
use strict;
our $VERSION = '1.12.0.1'; # TRIAL VERSION
sub new {
my $that = shift;
my $proto = ref($that) || $that;
my $self = $proto->SUPER::new(@_);
bless( $self, $proto );
$self->{commands} = {
install => 'pkg install -q --accept %s',
install_version => 'pkg install -q --accept %s',
remove => 'pkg uninstall -r -q %s',
update_package_db => 'pkg refresh',
};
return $self;
}
sub get_installed {
my ($self) = @_;
my @lines = i_run "pkg info -l";
my @pkg;
my ( $version, $name );
for my $line (@lines) {
if ( $line =~ m/^$/ ) {
push(
@pkg,
{
name => $name,
version => $version,
}
);
next;
}
if ( $line =~ m/Name: .*\/(.*?)$/ ) {
$name = $1;
next;
}
if ( $line =~ m/Version: (.*)$/ ) {
$version = $1;
next;
}
}
return @pkg;
}
1;