my %count; foreach my $e (@array) { $count{$e}++; } while (my($e,$count)=each(%count)) { print "$count\t$e\n"; }