sub readWords { ## Gets how many of each word are in a file and returns a hash my $file = shift; my %words = (); # What characters to ignore my $blacklist = qr{[\s~`!@#\$%\^&\*\(\)\{\}\+=\\\/\[\]\.\,<>\?;:"]+}; open(my $FILE, "<", $file) or die("$0: $file: $!\n"); while(my $currentline = <$FILE>) { $words{$_}++ for split $blacklist, $currentline; } close($FILE); return %words; }