evolution & bioinformatics
Wednesday, October 22, 2014
count redundant values in a array
my @array = qw(foo bar foo bar baz foo baz bar foo);
my %counts = ();
for (@array) {
$counts{$_}++;
}
foreach my $keys (keys %counts) {
print "$keys = $counts{$keys}\n";
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment