in reply to How to create multiple keys in a hash

Hi tanuja,

If I understand correctly, you want to count the occurences of elements of a list. If so, this might help.

#!/usr/bin/perl use strict; use warnings FATAL => 'all'; my @colours = ( "red", "green", "yellow", "green", "yellow", "green", + "blue", "red", "green"); my %count; $count{ $_ }++ for @colours; print "$_\t$count{ $_ }\n" for keys %count; __END__ output green 4 blue 1 red 2 yellow 2

Hope this helps