How to retrieve unique values from @array and store in %hash

by kalai 2008-12-04 18:43:59

conside @top array contains duplicate values, you can retrieve unique values and count of duplicate values and
store it in hash, hash is nothing but an associative array, it stores value along with the key.


my %hash = ();
foreach $s(@top){
++$hash{$s};
}


In the above code unique values from @top is retrieved and stored in %hash , here array values is stored as the key and
the count of duplicate value is stored as the value to the key.

Tagged in:

1559
like
0
dislike
0
mail
flag

You must LOGIN to add comments