Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My problem is occuring after a missing number has been found, I am struggling to get the counter to catch up with the number - I have tried +=1 and all sorts but my efforts mean that the wrong image is printed after the missing number (because the right image is only printed when the numbers are equal). How can I change this to still print one of the images after a missing number has been found??
Hopefully some code will explain this: Thanks a lot.
for my $counter ( 1..100 ) { for my $i ( @numbers ) { my $img; print "WELL: $i <P> GOAL: $counter<P>"; if ($i == $counter) { $img = $right[$counter-1]; } else { $img = "error.bmp"; $i -= 1; } $counter++; print qq(<area href="http:///cgi-bin/$img" >); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Real confusion with loops and counters
by Bilbo (Pilgrim) on May 30, 2003 at 11:53 UTC | |
|
•Re: Real confusion with loops and counters
by merlyn (Sage) on May 30, 2003 at 14:16 UTC | |
|
Re: Real confusion with loops and counters
by Itatsumaki (Friar) on May 30, 2003 at 14:20 UTC |