Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Problem in "index" function in recognizing repeating substrings

by saberworks (Curate)
on Sep 02, 2005 at 16:05 UTC ( [id://488694]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Problem in "index" function in recognizing repeating substrings
in thread Problem in "index" function in recognizing repeating substrings

No, his code clearly gives 0 and 6. If you want 0 and 2, try this:
#!/usr/bin/perl use strict; my $str = 'ATCGATCGAT'; my @sub = qw(ATCG CGAT); my $id = 0; foreach (@sub) { $id = index($str, $_, $id); print "$id\n"; $id++; }
  • Comment on Re^3: Problem in "index" function in recognizing repeating substrings
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found