<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package GLPI::Agent::Task::Inventory::HPUX::Softwares;

use strict;
use warnings;

use parent 'GLPI::Agent::Task::Inventory::Module';

use GLPI::Agent::Tools;

use constant    category    =&gt; "software";

sub isEnabled  {
    return
        canRun('swlist');
}

sub doInventory {
    my (%params) = @_;

    my $inventory = $params{inventory};
    my $logger    = $params{logger};

    my $list = _getSoftwaresList(
        command =&gt; 'swlist',
        logger =&gt; $logger
    );

    return unless $list;

    foreach my $software (@$list) {
        $inventory-&gt;addEntry(
            section =&gt; 'SOFTWARES',
            entry   =&gt; $software
        );
    }
}

sub _getSoftwaresList {
    my $handle = getFileHandle(@_);
    return unless $handle;

    my @softwares;
    while (my $line = &lt;$handle&gt;) {
        chomp $line;
        next unless $line =~ /^
            \s\s     # two spaces
            (\S+)    # name
            \s+
            (\S+)    # version
            \s+
            (\S.*\S) # comment
        /x;
        next if $1 =~ /^PH/;
        push @softwares, {
            NAME      =&gt; $1,
            VERSION   =&gt; $2,
            COMMENTS  =&gt; $3,
            PUBLISHER =&gt; 'HP'
        };
    }

    close $handle;

    return \@softwares;
}

1;
</pre></body></html>