I have a hash that is going to be used as a letter substitution key: A->B, B->F, C->J, etc. etc.
I have a message that's a scalar.
I'd love to use a regex with the hash keys and values to do this substitution in one or two lines if I can.
The alternative is to ginsu up the scalar into an array, switch each element of the array and then glue it back together into a scalar again.
Neither of these work. :(
# $mes =~ tr/(keys %codewheel)/(values %codewheel)/;
# $mes =~ tr/[keys %codewheel]/[values %codewheel]/;
Edit: Awesome, thanks guys. I recognize the \w and $1, but I didn't know how to include scalars into regex's. Thanks. Um, if we don't use the ()'s in (\w), will it scoop the whole message as one big pattern, or the whole first word or something?