in reply to Counting unique instances from Array Sort
The idiomatic way of eliminating duplicates creates an hash of counts as a byproduct.
my %counts; my @uniqueIPs = grep !$counts{$_}++, @ipAddresses; for my $ip (sort @uniqueIPs) { print("$ip ($counts{$ip})\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting unique instances from Array Sort: explanation needed
by bradcathey (Prior) on Jan 07, 2008 at 13:22 UTC | |
by ikegami (Patriarch) on Jan 07, 2008 at 17:35 UTC | |
by bradcathey (Prior) on Jan 07, 2008 at 19:09 UTC | |
by ikegami (Patriarch) on Jan 07, 2008 at 20:19 UTC | |
by Anonymous Monk on Jan 07, 2008 at 14:20 UTC | |
by NetWallah (Canon) on Jan 07, 2008 at 17:00 UTC |