while() { s/remove junk strings//og; my @words = split(/\s+/, $_); # split into words foreach my $w (@words) { $MyWordCount{lc($w)}++; } }