in reply to Need to find unique values in hash
Hi dipit,
We were talking about your question on the chat since it is not entirely clear what you want.
I suggested that you may need to change the way you use Dumper
use strict ; use warnings ; use Data::Dumper ; my %h = ( a => 1, b => [ 1, 2, 3], ) ; print Dumper(%h) ;
prints:
$VAR1 = 'b'; $VAR2 = [ 1, 2, 3 ]; $VAR3 = 'a'; $VAR4 = 1;
while
use strict ; use warnings ; use Data::Dumper ; my %h = ( a => 1, b => [ 1, 2, 3], ) ; print Dumper(\%h) ; # Note the additional \
prints
$VAR1 = { 'b' => [ 1, 2, 3 ], 'a' => 1 };
Hope this helps.
PS. Discipulus brought up map{ $hash{$_}=[ uniq(@{$hash{$_}}) ] } keys %hash using List::Util
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need to find unique values in hash
by dipit (Sexton) on Feb 04, 2019 at 12:45 UTC | |
by davido (Cardinal) on Feb 04, 2019 at 18:10 UTC | |
by dipit (Sexton) on Feb 05, 2019 at 08:01 UTC | |
by tobyink (Canon) on Feb 04, 2019 at 16:48 UTC | |
by Laurent_R (Canon) on Feb 04, 2019 at 13:59 UTC | |
by poj (Abbot) on Feb 04, 2019 at 13:02 UTC | |
by dipit (Sexton) on Feb 05, 2019 at 09:54 UTC | |
by dipit (Sexton) on Feb 05, 2019 at 08:00 UTC | |
by poj (Abbot) on Feb 05, 2019 at 08:17 UTC | |
by Don Coyote (Hermit) on Feb 04, 2019 at 21:36 UTC | |
by dipit (Sexton) on Feb 05, 2019 at 08:06 UTC |