Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: char substitution without regexes

by Soul Singin' (Initiate)
on Oct 02, 2010 at 16:12 UTC ( [id://863084]=note: print w/replies, xml ) Need Help??


in reply to Re: char substitution without regexes
in thread char substitution without regexes

Here's a variant on the above, but syntactically clearer:

#!/usr/bin/env perl use strict ; use warnings ; ## DNA string my $string = "aaaggctt"; ## syntactically clear hash my %hash = ( "a" => "t" , "g" => "c" , "c" => "g" , "t" => "a" ); ## print the DNA string and reverse complement ## add some extra spacing to make it look pretty print "\n" ; print "\t The DNA string is: " . $string . "\n" ; print "\tThe reverse complement is: " ; ## go through the string one element at a time ## and print reverse complement for my $i (0..length($string)-1) { print $hash{ substr($string, $i, 1) } ; } ## finish with a little extra spacing print "\n\n" ;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2026-04-22 21:26 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.