public
Last active

rot13 in Perl 6

  • Download Gist
rot13. not as simple as I'd hoped
1 2 3 4 5 6 7 8 9 10 11
sub rot13($s) {
join "", map { chr(do given ord($_) {
when ord('A')..ord('Z') { ($_ - ord('A') + 13) % 26 + ord('A') }
when ord('a')..ord('z') { ($_ - ord('a') + 13) % 26 + ord('a') }
default { $_ } })
}, $s.comb
}
 
say(rot13($_)) for
q[V'ir zrnfherq vg sebz fvqr gb fvqr:],
q['Gvf guerr srrg ybat, naq gjb srrg jvqr.]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.