#!/usr/bin/perl use strict; # NPR puzzler helper, 11/23/2003 # Find a pair of words, [X]rn and [X]m, which are antonyms. # We can pull all such pairs from /usr/share/dict/words. open(FH,"/usr/share/dict/words"); my @big_arr; # grep through it the slow way while () { if (/([a-zA-Z]*rn$)/) { push @big_arr, $1; } } #print @big_arr; close FH; # there's got to be a better way to do this. my @solutions; #print "|all_words| = ".$#all_words."\n"; my $curr_word; foreach (@big_arr) { $curr_word = substr($_,0,-2)."m"; my $cmd = 'grep ^'.$curr_word.'$ /usr/share/dict/words'; my $result = `$cmd`; if ($result) { push @solutions, "$_ / $curr_word\n"; } } close FH; print @solutions;