I spent at least an hour putting more and more and more DEBUG statements into my code, just to track down one nasty bug. This is the bug: I had this:
for(my $j = 0; $i < @ell_content; ++$j) {
instead of this:
for(my $j = 0; $j < @ell_content; ++$j) {
As the song goes, "It's tricky tricky tricky tricky HWUH!".
Evil C-style for loops (Score:2, Insightful)
for(my $j = 0; $j > @ell_content; ++$j)as
for my $j (0..@#ell_content)because you've only got
$jthere once instead of three times.Re:Evil C-style for loops (Score:2)
I go one up and avoid the index altogether:
I've only written one program I can think of in the last year where I needed the index, and I kept feeling like I was looking at the problem wrong.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:Evil C-style for loops (Score:2)
$thing[$j] = foo($thing[$j], $thing[$j+1]); splice @thing, $j+1, 1; next;Re:Evil C-style for loops (Score:1)