Try this. It does the lc() and the tr/// only once.
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11116620 use warnings; my @excluded = qw( a about although also an and another are as at be b +een before between but by can do during for from has how however in in +to is it many may more most etc ); local $/; my %count; $count{$_}++ for split ' ', (lc <>) =~ tr!-'@~,.()?*%/[]="!!dr; delete @count{@excluded}; print "$count{$_} $_\n" for sort { $count{ $b } <=> $count{ $a } || $a cmp $b } keys %count;
In reply to Re: Counting and Filtering Words From File
by tybalt89
in thread Counting and Filtering Words From File
by maxamillionk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |