in reply to Counting elements in array and outputing the count and item
The most elegant way is still to do this in the database:
select item, count(*) from mytable group by item
... but you can do the same in Perl by using a hash:
use strict; use Data::Dumper; my %count; my @status = ("Applied", "Enrolled", "Admitted", "Applied", "Enrolled" +);; $count{$_}++ for @status; warn Dumper \%count;
|
|---|