#!/usr/athena/bin/perl
print("Where is the ciphertext?\n");
$codefile = <STDIN>;
print("Where is the translation table?\n");
$transtab = <STDIN>;
chop($codefile);
chop($transtab);
open (FI, "$codefile") || die "No code file";
open (FT, "$transtab") || "No translation table";

while (<FT>) {
	if ($done) {
		@letters = split(//);
	}
	if (!$done) {
		@cipher = split(//);
	}
	$done =1;
	
}

grep($_ =~ tr/a-z/A-Z/, @letters);
while (<FI>) {
	$temp = $_;
	foreach $in (1..25) {
		foreach $x (0..25) {
		$s = $x +$in;		
		if ($s > 25) { $s = $s - 26; }
		$noc{$cipher[$x]} += s/$cipher[$x]/$letters[$s]/g;
		
		}
	print $_;
	$_ = $temp;
	}
#print $_;
}
close(FI);


for($x=0;$x<=26;$x++) 
{
print("$noc{$cipher[$x]} $cipher[$x] -> $letters[$x]\n");
}



