How about something like this:
#! /usr/bin/perl
use strict ;
use warnings ;
use Data::Dumper ;
my @match_arr = qw( count pick words ) ;
my %match_hash = map { $_ => 1 } @match_arr ;
my %word_count ;
while ( <DATA> )
{
my @words = split ;
for ( @words ) { $word_count{$_}++ if $match_hash{$_} }
}
print Dumper \%word_count ;
exit ;
__DATA__
This is my data.
I will first count all the
words herein, then pick and
choose the data I want. I can pick
the words using grep.
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche