use warnings; open (FILE, '' || $!); undef($/); while () { @array = split(/\ /, $_); my $word; foreach (@array) { print "$_\n"; } } for (@array){ s/[\,|\.|\!|\?|\:|\;|\"|\'|\<|\>]//g; $word{$_}++; } for (sort(keys %word)) { print "$_ occurred $word{$_} times\n"; }