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

If you want a substring from character 5 through character 10 including both then the substring length will be 10 - 5 + 1. The substr function counts offsets from zero so if you are counting from one you need to make an adjustment. The following code assumes you are counting like substr

# # 1 2 3 # 01234567890123456789012345678901234 my $seq = "LPNTGVTNNAYMPLLGIIGLVTSFSLLGLXKARKD"; # # Note that substr counts offsets from zero so adjust # if you are counting from one. my $start = 5; my $end = 10; my $length = $end - $start + 1; my $cut = substr $seq, $start, $length; print "$cut\n";

this prints

VTNNAY

Cheers,

JohnGG