Hello fellow monks!
I keep trying to understand why I am getting an exception error although it does not seem to be some kind of mistake. So, I have a script that is reading a file and storing some number ranges, which I will use to re-structure a string.
Initial string is something like:
PEGYNDRQAVNGSFYKLTFAPTFKVGSIGDFFSRPEIRFYTSWMDWSKKLNNYA
......................................................
and, with my script, I will replace the '.' with other characters. The script seems to stumble upon an error in this chunk:
while ($rest=~/\<REGION seq\_beg\=\"(\d+)\"\s+pdb\_beg\=\"\d+\"\s+seq\
+_end\=\"(\d+)\"\s+pdb\_end\=\"\d+\"\s+type\=\"(\w+)\"\/\>/mg)
{
$start=$1;
$end=$2;
$type=$3;
$TM_part_to_store = "$start-$end";
$length_part="$start-$end";
if($type==1)
{
substr($topo_initial, ($start-1), ($end-$start+1), ($side1 x (
+$end-$start+1)));
}
elsif($type==2)
{
substr($topo_initial, ($start-1), ($end-$start+1), ($opposite{
+$side1} x ($end-$start+1)));
}
elsif($type eq 'B')
{
push @all_TMs_line, $TM_part_to_store;
}
else
{
substr($topo_initial, ($start-1), ($end-$start+1), ('U' x ($en
+d-$start+1)));
}
}
where I am getting the info I need and change the '.' accordingly. For debugging, I made the script print the string length and each
$start and
$end, to see which substring is out of bounds, in the form of
string length <TAB> range
Weirdly enough, in the string that it fails, which has a length of
413 characters, the debugging prints the following:
413 1-6
413 7-15
413 16-34
413 35-46
413 47-53
413 54-67
413 68-83
413 84-85
413 86-95
413 96-112
413 113-118
413 119-133
413 134-142
413 143-153
413 154-160
413 161-174
413 175-181
413 182-186
413 187-193
413 194-217
413 218-224
413 225-237
413 238-244
413 245-266
413 267-273
413 274-282
413 283-290
413 291-304
413 305-311
413 312-320
413 321-328
413 329-347
413 348-355
413 356-369
substr outside of string at myscript.pl
As you can see, for some weird reason, and although my string's length is 413 chars and there are more ranges after
356-369, it exits with this error.
Any ideas?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.