Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Need to find unique values in hash

by dipit (Sexton)
on Feb 05, 2019 at 08:00 UTC ( [id://1229376]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Need to find unique values in hash
in thread Need to find unique values in hash

Thank you POJ. This really helped but i am still not able to figure out, how to print the duplicates? This way, only unique elements will be present in hash and i am successfully able to get the hash. Can you please help in providing how can i print which value/values are repeated for their respective keys?

Well, I need to print above according to this :

 ++$count2{$key}{$_} for @{$hash{$key}};

Replies are listed 'Best First'.
Re^5: Need to find unique values in hash
by poj (Abbot) on Feb 05, 2019 at 08:17 UTC

    Replace print Dumper \%count2 with this code.

    for my $key1 (sort keys %count2){ for my $key2 (sort keys %{$count2{$key1}}){ if ($count2{$key1}{$key2} > 1){ printf "%-10s %-10s %d\n",$key1,$key2,$count2{$key1}{$key2}; } } }
    poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-25 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found