in reply to Re: Re: Breaking output lines into N-element chunks
in thread Breaking output lines into N-element chunks
for my $i (0..@vars-1){ }
Oww oww oww! Make the hurting stop! Avoiding confusion between number-of-elements and last-valid-index is exactly why Perlish for loops are (usually) safer than C for loops. If you're going to be using $i as an array index, at least loop from 0 to $#vars instead of mucking about with length-1. IMO, your loop is more error-prone than a C-style loop, because eventually someone will forget the -1.
--
Good luck, tilly
:wq
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (FoxUni) Re(3): Breaking output lines into N-element chunks
by demerphq (Chancellor) on Apr 15, 2002 at 09:55 UTC | |
by Juerd (Abbot) on Apr 15, 2002 at 10:05 UTC | |
Re: (FoxUni) Re(3): Breaking output lines into N-element chunks
by demerphq (Chancellor) on Apr 15, 2002 at 09:54 UTC |