Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: simple letter substitution according to hash

by Jasper (Chaplain)
on May 16, 2006 at 18:01 UTC ( #549836=note: print w/ replies, xml ) Need Help??


in reply to simple letter substitution according to hash

s/$key/$value/g while ($key, $value) = each %codewheel;

also works, without any of the nasty joins, or evaluated regexes. Not sure I'd recommend it, though :)


Comment on Re: simple letter substitution according to hash
Download Code
That doesn't work.
by kbrint (Sexton) on May 16, 2006 at 20:14 UTC
    With the following:
    %codewheel = ( A => 'B', B => 'C', 'C' => 'D' );

    Your code changes 'ABC' --> 'BBC' --> 'CCC' --> 'DDD' and so on.

      Well spotted. That was stupid of me. I did say I didn't recommend it, didn't I? :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://549836]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-09-17 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (71 votes), past polls