#!/usr/bin/perl -w use strict; # List all non-common words in a block of text my %stopwords = (a => 1, an => 1, in => 1, the => 1); my %D2; while ( ) { @D2{ map { my $l = lc; exists $stopwords{$l} ? () : $l } split /\W+/ } = (); } print "$_\n" for sort keys %D2; __DATA__ This is a demo of an interesting example in the post from PerlMonks.