Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How can I count the number of substitutions of one letter in a string by another letter in the other string?

by BrowserUk (Patriarch)
on May 11, 2012 at 18:58 UTC ( [id://970079]=note: print w/replies, xml ) Need Help??


in reply to How can I count the number of substitutions of one letter in a string by another letter in the other string?

Using individual named vars makes this awkward. Using a hash, makes it simple:

#! perl =slw use strict; use Data::Dump qw[ pp ]; my $seq1="AAAGATCGTG"; my $seq2="AGTACTTTCC"; my %subs; for my $p ( 0 .. length( $seq1 ) - 1 ) { my $c1 = substr $seq1, $p, 1; my $c2 = substr $seq2, $p, 1; next if $c1 eq $c2; ++$subs{ $c1 . '2' . $c2 }; } pp \%subs; __END__ C:\test>junk.pl { A2C => 1, A2G => 1, A2T => 1, C2T => 1, G2A => 1, G2C => 1, G2T => 1 +, T2C => 1 }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re: How can I count the number of substitutions of one letter in a string by another letter in the other string?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I count the number of substitutions of one letter in a string by another letter in the other string?
by spazm (Monk) on May 11, 2012 at 20:40 UTC
    ooh, very pretty.
    Thanks, I was hoping to see something nice today.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found