Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Comparing 2 different-sized strings

by roboticus (Chancellor)
on Aug 08, 2013 at 17:11 UTC ( [id://1048608]=note: print w/replies, xml ) Need Help??


in reply to Comparing 2 different-sized strings

AdrianJ217:

Something like this should work:

my $s1='TCGAGTGGCCATGAACGTGCCAATTG'; my $s2='ATGATCCTG'; ($s1,$s2) = ($s2,$s1) if length($s1) > length($s2); my $loc = index $s2, $s1; if ($loc<0) { print "String not found!\n"; } else { print "String found at location $loc\n"; }

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Comparing 2 different-sized strings
by Laurent_R (Canon) on Aug 08, 2013 at 17:16 UTC

    The OP wants to allow for some mismatches. The index function is not suitable for that.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-18 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found