in reply to hash to count words
#!/usr/bin/perl -w while (<>) { $COUNT{$_}++ for map lc, split /\W+/; } print "$_: $COUNT{$_}\n" for sort keys %COUNT;
Or if you're only interested in certain words...
#!/usr/bin/perl -w @W = qw( hello world ); while (<>) { $COUNT{$_}++ for grep { $_~~@W } map lc, split /\W+/; } print "$_: $COUNT{$_}\n" for sort keys %COUNT;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
In Section
Seekers of Perl Wisdom