local $/ = undef; $_ = ; my %hash = (); $hash{$_}++ foreach split /[^\w']+/; # Change $_ to lc if case matters