my %distinct; for my $aref ( @result ) { $distinct{$aref->[0]}++; } print Dumper(\%distinct);