#!/usr/bin/perl if ($ARGV[0] eq $ARGV[1]) { die "Arguments are the same.\n"; } if ($ARGV[0] gt $ARGV[1]) { die "Filenames should be in order.\n"; } open RULE1, "<$ARGV[0]" || die "could not open $ARGV[0]\n"; open RULE2, "<$ARGV[1]" || die "could not open $ARGV[1]\n"; while() { #feed words into some data structure #then close this loop chomp $_; @words = split; for $word (@words) { #print $word, "\n"; while($word =~ s/\W//) {} $word = lc $word; #print "$word\n"; $rule1{$word}++; } } #, and go through rule2 comparing words while() { chomp; @words = split; for $word (@words) { while($word =~ s/\W//) {} $word = lc $word; $rule2{$word}++; unless($rule2{$word} > 1) { if( $rule1{$word} > 0) { $matches++; $matches{$word}=1; } } } } if($matches > 6) { print "I found ", $matches, " different matches between files "; print $ARGV[0] , " and " , $ARGV[1] , "\n" ; for $keys (keys %matches) { print $keys, "\n"; } } close RULE1; close RULE2;