in reply to Re: get substring when you know START and END???
in thread get substring when you know START and END???

Try a little arithmetic. The number of characters in a substring is (end - start) +1.

Perl counts the leftmost position (as shown in my English language world) as position '0'. Presuming you want the string between positions 5 (counting from 0, that would be "V" in the string you show) and 10 (which, if I counted right) is "Y", you would be including "TNNA" (this is what you specified, but is it what you want?), which would be

$sub = substr($seq,6, 4);

If you want the characters in positions 5 through 10, you would write something like:

$sub = substr($seq, 5, 6);

which would (again, if I counted right) return "VTNNAY" -- the characters in positions 5 through 10.

emc

"Being forced to write comments actually improves code, because it is easier to fix a crock than to explain it. "
—G. Steele