in reply to Rot13 Source Jumbling
Basically you want something along the lines of:
# # Warning: untried code # my $message = "Blah!"; my (%translation); my $alphabet = join('', (a..z)); # Cheezy, but does 2 passes, performing a uc() in between foreach (0..1) { my $startchar = ord(substr($alphabet, 0, 1)); foreach my $c (0..25) { $translation{chr($startchar + $_)} = substr($alphabet, $_ - 13, 1); } $alphabet = uc($alphabet); } # %translation now contains the value for each character # in ('a'..'z', 'A'..'Z') print("Old message: ", $message, "\n"); my @letters = split('', $message); my (@newmessage); while (@letters) { my $c = shift(@letters); $c = $translation{$c} if (defined($translation{$c})); push(@newmessage, $c); } $message = join('', @newmessage); print("New message: ", $message, "\n");
Others may know a better way to implement it, and I look forward to seeing their postings. Hope it at least helps.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Rot13 Source Jumbling
by ibanix (Hermit) on Dec 07, 2002 at 03:47 UTC | |
|
Re: Re: Rot13 Source Jumbling
by Anonymous Monk on Dec 07, 2002 at 04:03 UTC |