How about this?
use Modern::Perl; my %seen; while( <DATA> ) { chomp; $seen{$_}++; } my @top = ( sort { $seen{$b} <=> $seen{$a} } keys %seen )[0,1]; foreach ( @top ) { say "$_ $seen{$_}"; } __DATA__ 1.1.1.1 2.2.2.2 1.1.1.1 4.4.4.4 1.1.1.1 4.4.4.4
Dave
In reply to Re: Top n Unique count from Array
by davido
in thread Top n Unique count from Array
by cipher
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |