# 
# I decided to take a regex approach--  feed it the name of a dictionary file 
# as the argument...  -Alan
# 

use strict;
my (%goodones, %sequences);

open(DICT,$ARGV[0]) || die $!;
while (chomp($_ = <DICT>)) {
   /(\w{4})(?{$sequences{lc $1}++; $goodones{lc $1} = $_})(?!)/g;
}
close(DICT);

open(QUESTIONS,">questions") || die $!;
open(ANSWERS,  ">answers"  ) || die $!;

for (sort keys %sequences) {
   next unless $sequences{$_} == 1;
   print QUESTIONS "$_\n";
   print ANSWERS   "$goodones{$_}\n";
}

close(QUESTIONS);
close(ANSWERS);

