#!/usr/local/bin/perl -w use strict; use Getopt::Std; use vars qw($opt_w); getopts('w:') || die "Bad options.\n"; my $dict = $opt_w || 'wordlist'; open(DICT, $dict) or die "Can't open $dict: $!\n"; my $crypto = shift; my $match = &crypto_canon($crypto); while () { chomp; next if length $match != length $_; next if $match ne &crypto_canon($_); print "$_\n"; } sub crypto_canon { my($word) = @_; my $canon; my %letters; my $next = 'a'; foreach (split //, $word) { if ($_ !~ /[a-z]/) { $canon .= $_; next; } elsif (not exists $letters{$_}) { $letters{$_} = $next++; } $canon .= $letters{$_}; } $canon; }