#!/usr/bin/perl use strict; ( @ARGV == 2 and -f $ARGV[0] and -f $ARGV[1] ) or die "Usage: $0 stopword.list document.file\n"; my ( %stopwords, %docwords ); my ( $stopword_name, $document_name ) = @ARGV; open( I, "<", $stopword_name ) or die "$stopword_name: $!"; while () { my @words = grep /^[a-z]+$/, map { lc() } split /\W+/; $stopwords{$_} = undef for ( @words ); } close I; open( I, "<", $document_name ) or die "$document_name: $!"; while () { for ( grep /^[a-z]+$/, map { lc() } split /\W+/ ) { $docwords{$_} = undef unless ( exists( $stopwords{$_} )) } } close I; for (keys %docwords) { print "$document_name\t$_\n"; }