Hello Ashwin,
I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each element has occurred in the same array. for example 1-5 times 2-3 times... could some one throw some light on how i can do this.
Store the array contents into a hash, updating the count each time: =pod code #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my @elements = ( 1, 2, 3, 4, 2, 3, 1, 2, 1, 1, 1, 4, 6, 7, ); my %count; $count{$_}++ for @elements; print Dumper \%count; =cut Regards, Alan Haggai Alavi. -- The difference makes the difference -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/