http://www.perlmonks.org?node_id=864280


in reply to article processer

open(E,shift @ARGV) or die($!); chomp(@e=<E>); close(E); undef $/; $t=<>; printf("%-20s : %3d\n", "Words:" ,scalar split(' ',$t)); printf("%-20s : %3d\n ", $_, scalar(@a=($t =~ m/$_/mgi))) for @e;

Good enough to do the work, bad enough to fail a test. As a homework assignment, find out how this works and then rewrite it in a decent way.

Hint: takes as arguments one file with a list of words/expressions and a list of files to be processed.