#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; for (qw( foo bar bar foo ber foo bir foo bor foo bur )) { $hash{$_} ++; } print Dumper \%hash;