in reply to Re: For loop abortions
in thread For loop abortions

But the outer  for my $i (0..scalar @sig) { ... } in both loop examples still seems to me to have an inherent off-by-one error. This error is masked by the fact that  $#sig is used as the range limit in the  $i+1..$#sig range expression of both inner loops.

But the inherent error (as I consider it) still remains, and must be fixed up or masked or otherwise dealt with in some way, and poses a potential pitfall for future programmers and maintainers. Why not use the more idiomatic (and IMHO correct)  for my $i (0 .. $#sig) { ... } form in both outer loops?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: For loop abortions
by Laurent_R (Canon) on Mar 18, 2016 at 18:34 UTC
    Yes, you are absolutely right, AnomalousMonk, I copied and pasted part of the original code too hastily. This is still quite messy, even if it works.

    I'll fix that for future reference immediately after my answer.

    The other point is that I am not convinced by the algorithm and I suspect it is probably not really what the OP wants, I have trouble finding a use case that would really make sense out of that, but I do not know what the OP wants would really and we don't have enough information, at least not at this point, to be sure.

    Thank you very much.