#!/usr/bin/perl use strict; use warnings; # starting data $_ = 'HHJHPAPAJJAJPJJHAAJJAAJHJAHAJPHJHAHPPJ HAAHHJJJHJPPHPHJAJPHAAPHAJJHHJHAHA'; # strip newline within $_ s,\s,,s; # turn letters in $_ into numbers tr/JAPH/0123/; # turn every 3 numbers into a single character s;(.)(.)(.);tadman($1,$2,$3);eg; # do some case mapping s;\w+;\L\u$&;g; # show the deciphered message {print} sub tadman { # $1, $2, and $3 from the substitution my ($A, $B, $C) = @_; # be upfront about math my $index = $A * 16 + $B * 4 + $C; # here's the data from whence comes the non-trademarked message my @key = split /|/, 'KnKttiIMRsROhOppllrr y ssLfL cWEdEaauujj'; # here's the uncompressed data, that we can now index into my @expanded_key = map { ord > 0130 ? $_ : (), $_ } @key; # pull out the $index-th letter from @expanded_key my $value = $expanded_key[$index]; return $value; }