undef($/); while () { } #### undef($/); $_ = ; #### s/[\,|\.|\!|\?|\:|\;|\"|\'|\<|\>]//g; #### s/[\,\.\!\?\:\;\"\'\<\>||||||||]//g; #### s/[\,\.\!\?\:\;\"\'\<\>|]//g; #### s/\,|\.|\!|\?|\:|\;|\"|\'|\<|\>//g; #### s/[\,\.\!\?\:\;\"\'\<\>]//g; #### @array = split(/\ /, $_); s/[\,\.\!\?\:\;\"\'\<\>]//g; #### @array = split(/ /, $_); s/[,.!?:;"'<>]//g; #### '' || $! #### '' #### @array = split(/ /, $_); #### @array = split(' ', $_); #### use strict; use warnings; my $file; { my $qfn = ''; open(my $FILE, '<', $qfn) or die("Can't open \"$qfn\": $!\n"); local $/; $file = <$FILE>; } my %word_counts; for (split(' ', $file)) { s/[,.!?:;"'<>]//g; ++$word_counts{lc($_)}; } for my $word (sort keys(%word_counts)) { print "$word occurred $word_counts{$word} times\n"; } #### use strict; use warnings; my %word_counts; while (<>) { for (split(' ', $_)) { s/[,.!?:;"'<>]//g; ++$word_counts{lc($_)}; } } for my $word (sort keys(%word_counts)) { print "$word occurred $word_counts{$word} times\n"; }