Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: comparing strings

by termix (Beadle)
on Oct 30, 2002 at 15:23 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found