@ca = (sub { @kp = split(//, shift @_, 0); $c = shift @_; $p2{' '} = ' '; $C2{' '} = ' '; foreach $_ (@kp, ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')) { if (not exists $p2{$_}) { $k = chr 65 + ($a++ + $c) % 26; $p2{$_} = $k; $C2{$k} = $_; } } } , sub { $t = shift @_; $h = shift @_; foreach $_ (split(//, $t, 0)) { $r = $r . $$h{$_}; } return $r; } ); $ca[0]->('thequickbrownfoxjumpsoverthelazydogs', 10); print $ca[1]->('ZOCK FWUKLMT BMTE LFQR', \%C2) . "\n"; #### # @ca - code array # @kp - key phrase # $c - caesar shift (big hint here) # %p2 - short for p2C - plaintext to CIPHERTEXT hash # %C2 - short for C2p - CIPHERTEXT to plaintext hash # $k - key (one letter of the key alphabet) # $t - text # $h - hash reference # $r - result