in reply to keep only unique elements in an array displaying number of duplicates.

Using DBI and DBD::CSV:
use Modern::Perl qw/2014/; use DBI; my $dbh = DBI->connect("dbi:CSV:"); my $query = "SELECT col1, count(col1) AS counter FROM test.csv WHERE col5 = 'yes' + GROUP by col1 ORDER BY col1"; my $sth = $dbh->prepare($query); $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { say $row->{col1}, "\t", $row->{'counter'}; }
Output:
dave 2 james 2 jon 4 ken 1 mike 1

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics