#!/usr/bin/perl -w # supply as STDIN your file of encrypted names # KCRVKXHL EUJDXZ # WKNJVWL GSWOXU # HYUE WREEYCS # ... # There is an optional 2nd argument in the call to iso() # to specify a different name list so you can have different # files for first and last names, and male and female names. sub iso { @array=(); $name=shift; $file=shift; $file="name_list.txt" unless defined($file); pipe(RH,WH) or die("pipe $!"); $pid=fork(); die("fork $!") unless (defined($pid)); if (0==$pid) { close(RH); open(STDIN,"<$file"); open(STDOUT, ">&WH"); open(STDERR, ">&WH"); exec("./isomorph", "$name"); } close(WH); while () { chomp(); push(@array, $_); } close(RH); waitpid($pid, 0); return @array; } ##################################### sub consistent { my ($efirst, $elast, $first, $last); $efirst=shift; $elast=shift; $first=shift; $last=shift; return "BAD" if (length($efirst) != length($first)); return "BAD" if (length($elast) != length($last)); %c2p=(); %p2c=(); return "BAD" if ("BAD" eq tabulate($efirst, $first)); return "BAD" if ("BAD" eq tabulate($elast, $last)); return "MAYBE"; } ##################################### sub tabulate { $ctext=shift; $ptext=shift; return "BAD" if (length($ctext) != length($ptext)); for ($i=0 ; $i) { # read an encrypted full name into ($efirst, $elast) chomp(); ($efirst, $elast)=split(/\s+/); open(STDOUT, ">$efirst-$elast"); # ismorph the first name and store the resulting list @allfirst=iso($efirst); # ismorph the last name and store the resulting list @alllast=iso($elast); # multiply the 2 lists # check the first+last for consistency # show what passes these tests for human selection foreach $last (@alllast) { foreach $first (@allfirst) { next if ("BAD" eq consistent($efirst, $elast, $first, $last)); printf("%s %s\n", $first, $last); } } } exit(0);