On Sep 17, 2012, at 6:52 AM, Shlomi Fish wrote: > Hi, > > I apologise for having sent that to Dr. Rathbun in private - that was not my > intention but a misuse of software. Resending to the list. > > On Sun, 16 Sep 2012 19:31:01 -0700 (PDT) > jmrhide-p...@yahoo.com wrote: > >> for (my $loopiter = 0; $loopiter < $loopmax; $loopiter++) { #1 >> if ($loopiter >= ($loopmax - 1)) { die "Loop number >> $loopnum has iterated $loopiter times" } > > This line (#2) will throw an exception in the final iteration of the loop, > so it's not good.
I think you missed the part where the loop is supposed to terminate before $loopiter becomes equal to $loopmax, and if it does not terminate before then, it is an error. > You can use: > > for my $loopiter (0 .. $loopmax-1) > { > } I would make that for my $loopiter ( 1..$loopmax ) and get rid of the two subtractions. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/