Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: char substitution without regexes

by oko1 (Deacon)
on Sep 30, 2010 at 18:41 UTC ( [id://862828]=note: print w/replies, xml ) Need Help??


in reply to char substitution without regexes

Good rule of thumb: whenever you think "lookup table", your next thought should be "use a hash".

my (@list, %find); @list = qw/a t g c/; # You can do it manually... @find{@list} = qw/t a c g/; # ...or programmatically: @find{@list} = map {reverse @list[$_*2, $_*2+1] } 0..@list/2-1; print "$_: $find{$_}\n" for @list;

Output:

a: t t: a g: c c: g

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2026-04-13 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.