open (FILE, "foo.txt"); my @words = map { s/[.,!\?]\B//g; split; } ; close FILE;