in reply to While issues
should berand(0 .. $total)
rand($total+1)
Actually, it probably be should be
rand(0+@aob)
If any element of @aob can be picked, why rely on some external value.
(Technically, the "0+" is unnecessary because of rand's prototype, but that's fairly obscure.)
By the way, $cnr is unneeded. I also got rid of q{} because it just doesn't stand out as much as the default quotes.
while (1) { my $xda = int rand( 0+@aob ); if ( $aob[$xda][ $y - 1 ] ne "") { $aob[$x][$y] = $z + $aob[$xda][ $y - 1 ]; last; } }
|
|---|