in reply to More while issues

I apologise if you are using carefully chosen Turkish or Nepalese words for your variable names, but to me they are meaningless gibberish. I think you are trying to compress things too much, I suspect $chntot is a count. You aren't charged by the character, you can be a little more verbose.

They don't need to be very long names, that's for Java. But complete words and well-known contractions are good. The length of a name should be proportional to the scope of it's use. In a small loop you might use i or idx; a long-lived variable might be @playingcard_suits.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Replies are listed 'Best First'.
Re^2: More while issues
by Dandello (Monk) on Mar 05, 2011 at 00:47 UTC

    Considering the vast majority of my variables look like $dr5[$rn] and $datay{$data[$drp]}, $chntot (change total) is clear as day.

    We really need smileys here. - I wonder what chntot means in Nepalese.

    This is the latest working version BTW

    sub rankdwn { my ( $yb, $chntot, $incrsdel ) = @_; my $cnd_a = $aod[$yb] =~ tr/a/a/; my $cnd_y = $aod[$yb] =~ tr/y/y/; my $letter = 'a'; if ( ( $cnd_a + $cnd_y ) <= $incrsdel ) { $aod[$yb] =~ s/a/y/gsxm; $cnd_y += $cnd_a; $letter = 'c'; } while ( $cnd_y < $incrsdel ) { my $xda = int rand( $chntot + 1 ); if ( substr( $aod[$yb], $xda, 1 ) eq $letter ) { substr $aod[$yb], $xda, 1, 'y'; $cnd_y++; } } return; }