in reply to Re^10: Comparing 2 different-sized strings
in thread Comparing 2 different-sized strings

Oh, sorry. In the part of the code where you have:
sub hd{ length( $_[ 0 ] ) - ( ( $_[ 0 ] ^ $_[ 1 ] ) =~ tr[\0][\0] ) }
You are submitting 2 parameters (2 dna sequences) to the subroutine, so in the above code which computes the hamming distance, how do you know which variable refers to which sequence? Or could you just explain what the code above is doing? Thank you so much!

Replies are listed 'Best First'.
Re^12: Comparing 2 different-sized strings
by BrowserUk (Patriarch) on Aug 13, 2013 at 21:06 UTC

    See perldoc/perlsub for details, but basically $_[0] is the first parameter passed; $_[1] is the second; and so on.

    You could always name them in the usual way, but why bother with such a simple subroutine. Beside which, it is more efficient not to.


    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.
Re^12: Comparing 2 different-sized strings
by choroba (Cardinal) on Aug 13, 2013 at 20:41 UTC
    The distance between A and B is the same as the distance between B and A. You do not need to know.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ