My guess is that your debugging only shows the initial length of the string, but not the current one.
If one of your previous replacements resulted in a shorter string because of a bug, you'll end up out of bounds.
see also hv's remark
> is length($opposite{$side1}) always 1.
I may add the same question for $side1 ...
On a side note: another critique to your code is that you are escaping too many elements in your regex, neither _ nor " are meta.
furthermore are you relying on input coordinates you are parsing, but without validating their correctness.
I can imagine various scenarios how this could fail.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re: substr out of str error - but why?
by LanX
in thread substr out of str error - but why?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |