in reply to Re^3: Yet more While issues
in thread Yet more While issues
Habit
I'm still trying to get everything configured to work right - When I have the code set up like this:
thenelse { my $pos = -1; push @cPosns, $pos while ($pos = index($zazb, 'c', $pos+1)) >= 0; my $offset = $cPosns[rand @cPosns]; $cell = sprintf '%.2f', popnum3( $x, $y, $copycop, $offset, ); }
It's reiterating over the entire string for every single 'a' or 'c' which starts fast then slows to a crawlsub popnum3 { my ( $x, $y, $z, $offset ) = @_; if ( $y == 0 ) { $aob[$x][0] = $initial * ( 1 + $z ); } else { while (1) { $aob[$x][$y] = $aob[$offset][ $y - 1 ] * ( 1 + $z ); last; } } return $aob[$x][$y]; }
When I move this section
above all the if/else's, to just under where $zazb is defined, then the $offset variable inmy $pos = -1; push @cPosns, $pos while ($pos = index($zazb, 'c', $pos+1)) >= 0;
becomes undefined when imported into popnum3.else { my $offset = $cPosns[rand @cPosns]; $cell = sprintf '%.2f', popnum3( $x, $y, $copycop, $offset, ); }
So obviously I'm still missing something.
There is always at least 1 'c' in the string so that's not the problem.
|
|---|