use strict; use warnings; use Data::Dumper; my %count; my @array = qw(John Sue Larry Mary John Mary Larry John Joe Lisa John Mary); grep {++$count{$_}} @array; print Dumper \%count;