#!/usr/bin/perl -w use strict; my %histogram; my @wordstofind = qw( a am an and are as at be been but by can co de do due each ); #Many more words snipped while () { my @currentline = split; $histogram{$_}++ for @currentline; } foreach my $i (@wordstofind) { while ( my ($key, $value) = each (%histogram) ) { if ($key =~ /$i/) { print "Found $key, $value times\n"; } } }