In article <AANLkTi=afy09dh8c2f3tmncjcm4om1ihgutacaln_...@mail.gmail.com>, ashwint...@gmail.com (ashwin ts) wrote:
> Hi, > > I am a newbie to perl. > 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. > thanks in advance.. > > Regards > Ashwin Thayyullathil Surendran quick write, not tested : my @array = (1,2,3,4,2,3,1,2,1,1,1,4,6,7); my @freq; for (@array) { $freq[$_]++;} my $i=0; for (@freq) { print "$i : $_ times\n"; $i++; } -- klp -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/