Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: comparing strings

by termix (Beadle)
on Oct 30, 2002 at 15:23 UTC ( #209103=note: print w/replies, xml ) Need Help??

in reply to comparing strings

I think getting one scalar out of a pair of arrays is going to give you one list (rather than the pair you want to compare). You can try this by adding a print $base line right inside the loop and seeing how many times it loops. Also, unless lines1 is an array of arrays, you want to get your character from it through a scalar like $lines1[0].

Depending on how good you are with perl you might find the following alternate too simple (or too c-like) but the foreach loop can replace the for loop (I think). And I never liked shifting.

# e.g @lines1 contains CACTATGAGTGATCGC and @lines2 contains # ACTGACTAATGCGTTG. @lines1= split(//,"CACTATGAGTGATCGC"); @lines2= split(//,"ACTGACTAATGCGTTG"); $line1length=@lines1; $line2length=@lines2; print ("1 :",@lines1,"\n"); print ("2 :",@lines2,"\n"); if ($line1length!=$line2length) { print "Length Mismatch\n"; } else { print "M :"; for ($x=0;$x<$line1length;$x++) { if ($lines1[$x] eq $lines2[$x]) { print $lines1[$x]; } else { print "*"; } } print "\n"; }

-- termix

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2023-06-06 02:14 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.