in reply to Excluding words with more than three a

How about this:

#!/usr/bin/perl -w use strict; open(WORDS, "<dictionary.txt") || die "Cannot open dictionary file."; foreach(<WORDS>){ if(!/b.*b/ && !/a.*a.*a/ && !/k.*k/ ){ push(@_, $_); } } close(WORDS); print @_,; exit;