#!/usr/bin/env perl use strict; use warnings; use Data::Dumper qw( Dumper ); my $string = "Hello World!\n Oh poor Yorick, his world I knew well ye +s I did"; # No change up to here # then just map ++$_,@count{split /\W+/,uc $string}; # that's it print "Word count: ", Dumper(%count); 1;