while (1) { my $xda = int rand (0 .. $total); if ( $aob[$xda][ $y - 1 ] ne q{}) { $aob[$x][$y] = $z + $aob[$xda][ $y - 1 ]; last; } }