List::UtilsBy
use List::UtilsBy qw( count_by ); use Proc::ProcessTable qw(); use Data::Dumper qw( Dumper ); my $procs = Proc::ProcessTable->new->table; my %tally = count_by { scalar getpwuid($_->uid) } @$procs; say Dumper(\%tally);
$VAR1 = { 'syslog' => 1, 'root' => 139, 'www-data' => 7, 'grant' => 67, ... };