in reply to While issues

There is nothing fundamentally wrong with the while portion of the construct. My guess would be that your conditional $aob[$xda][ $y - 1 ] ne q{} never evaluates to true. Are you sure it contains what you think it does? See How can I visualize my complex data structure? (short answer Data::Dumper).

On a side note, if $cnr is never used outside this context, I would use last (see Loop Control) to control flow:

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

Update: I think windikegami has the answer abovebelow.