in reply to Similarity of strings

Use the XOR!

my $x = "EKFCNSVVDLYSNLSKPFLDIVLYIFKLTSAIGAQGPA----SMMAYLVV"; my $y = "ERFCRQLSSMASKLI-------ISPFTLVYYTYQCFQSTGWPVSIFGYFI"; my $z = $x^$y; my $score = ($z =~ tr/\0//); return $score/length($x)

Replies are listed 'Best First'.
Re: Re: Similarity of strings
by professa (Beadle) on May 15, 2002 at 15:35 UTC
    XOR seems to be the fastest method! It needs ~3 seconds instead of ~7 seconds using SUBSTR. Well, more than twice the speed, cool! ;-)

    Thanx, Micha