Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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
Replies are listed 'Best First'.
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 pondering the Monastery: (11)
As of 2015-07-31 07:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (275 votes), past polls