#!/usr/bin/perl use strict; use Data::Dumper; use constant PROG_NAME => 10; my $what_im_looking_for = 'JVM'; my %ps_hash; my @ps = `ps aux`; foreach (@ps) { my @tmp = split; next if ($tmp[PROG_NAME] ne $what_im_looking_for); $ps_hash{$tmp[PROG_NAME]}{cpu} += $tmp[3]; $ps_hash{$tmp[PROG_NAME]}{mem} += $tmp[4]; $ps_hash{$tmp[PROG_NAME]}{time} += $tmp[9]; } print Dumper(\%ps_hash);