use strict; use Data::Dumper; my @items = ('this', 'that', 'that', 'those', 'these', 'them', 'thou'); my $bag; map {$bag->{$_}++} @items; print Dumper($bag); __END__ $VAR1 = { 'these' => 1, 'those' => 1, 'thou' => 1, 'them' => 1, 'that' => 2, 'this' => 1 };