An illustration of the problem lies in the code above.my @main = ( "<UL>\n", "<!--begin-->\n", "</UL>\n" ); &getboardinfo(); sub getboardinfo { my($tnum); $msgcount = 0; $lastmsg = 0; $lastfu = 0; $fucount = 0; print STDERR "Going into loop: main is @main\n"; print STDERR "main has ", $#main + 1, " elements.\n"; for( $j=0; $j<=@main; $j++ ) { print STDERR "Loop! j is $j main[j] is $main[$j] main[j+2] is + $main[$j+2]\n";
if( $main[$j] =~ /<!--top: (.*)-->/ ) { $msgcount++; $lastmsg = $1; } elsif( $main[$j] =~ /<!--ins: (.*)-->/ ) { $tnum=$1; if( ( $main[$j+1] =~ /<!--end:/ ) &&( $main[$j+2] =~ /<!--end:/ ) ) { $lastfu = $tnum; $fucount++; } } } print STDERR "Done with loop\n"; return 0; }
Of course, the original writer should probably have found
a better way to write this loop (maybe by using foreach()).
Rob
|
|---|