Something like
my
%hash;
for
(my $i=0;$i<@array;$i++) {
if (!$hash{$array[$i]}) {
$hash{$array[$i]} = 1;
} else {
$hash{$array[$i]}++;
}
}
foreach $key (keys %hash) {
print "Name: $key count =
$hash{$key}\n";
}
-- Jay
Mumper
-----Original Message-----
From: Heiko Nieke [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 06, 2002 11:03 AM
To: [EMAIL PROTECTED]
Subject: Count how often a certain element occurs in an arrayHi,
It might be a silly question, but I am new to perl and I need to solve the following problem
- I have a list with approx. 400000 names
for example:
Christian
Sally
Christian
Klaus
....Now I need to know how often each name appears in the list. Could anybody help me doing this with a perl script?
Thanks
Heiko
