in reply to Re^2: Need to find unique values in hash
in thread Need to find unique values in hash
Not sure which way you want the grouping count1 or count2.
poj#!perl use strict; use Data::Dumper; my %hash = ( '33|srv2' => [ 'users','users','users', 'admin','admin','admin', 'manager','manager','manager' ], '27|rufserv3' => ['system'], '16|lbapp0112' => [ 'admin (priv1', ' priv2)' ], '34|srv2' => [ 'users', 'users', 'users', 'admin', 'admin', 'manager' ] ); #print Dumper %hash; my %count1; my %count2; for my $key (keys %hash){ ++$count1{$_}{$key} for @{$hash{$key}}; ++$count2{$key}{$_} for @{$hash{$key}}; } print Dumper \%count1; print Dumper \%count2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Need to find unique values in hash
by dipit (Sexton) on Feb 05, 2019 at 09:54 UTC | |
|
Re^4: Need to find unique values in hash
by dipit (Sexton) on Feb 05, 2019 at 08:00 UTC | |
by poj (Abbot) on Feb 05, 2019 at 08:17 UTC |