#!/usr/bin/perl use Getopt::Std; getopts("u:mw:d:"); #defualt file locations over ride with option -d <path> $wordlist = "/usr/share/lib/dict/words"; $database = "$ENV{HOME}/.word_db"; #option -u(nscramble) ... if($opt_u){ #open default if not specified open(IN, $opt_d ? "<$opt_d" : "<$database"); #build the lookup table while(<IN>){ ($value, $key) = split /:/; chomp $key; $hash{$key} = $value; } #arange the letters to match format of database $sorted = join "",sort split//,$opt_u; #display unscrambled word print $hash{$sorted}."\n"; } #build the database file, -m(ake) elsif($opt_m){ open(IN, $opt_w ? "<$opt_w" : "<$wordlist"); open(OUT, $opt_d ? ">$opt_d" : ">$database"); #write lookup table, word:sorted letters while(<IN>) { chomp; $sorted = join "",sort split//; print OUT "$_:$sorted\n"; } } else { print "Usage: ./$0 [-m] [-w[wordlist]] [-d [database]][-u scramble +dword]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Jumble" solver
by LAI (Hermit) on Jan 24, 2003 at 15:01 UTC | |
|
Re: "Jumble" solver
by Hofmator (Curate) on Jan 24, 2003 at 16:08 UTC | |
|
Re: "Jumble" solver
by Coruscate (Sexton) on Jan 25, 2003 at 02:59 UTC | |
by Anonymous Monk on Apr 03, 2003 at 14:46 UTC | |
by Anonymous Monk on Apr 03, 2003 at 14:48 UTC |