|
|
| Do you know where your variables are? | |
| PerlMonks |
Re^6: More while issuesby Dandello (Beadle) |
| on Mar 07, 2011 at 01:10 UTC ( #891730=note: print w/ replies, xml ) | Need Help?? |
|
Copying and using the entire subroutine above now gets me a line that should only have 'c's, 'y's and 'x' as: It also throws a lot of 'undefined value in $offset' and 'splice offset past end of array' warnings - which is why I had put push @cPosns, pos $str while $str =~ m{(?=c)}g; within a while statement. It doesn't throw warnings and does convert the proper number of 'a's and 'c's into 'y's. But it also doesn't give me my necessary randomness. All the 'y's are 'right' aligned. As for what happens if there aren't enough 'c's? - That possibility has been caught well before this subroutine. The $chntot was still listed as I have been a<->b-ing between my older (working) subroutine and this one. The other subroutine calls for $yb, $incrsdel and $chntot. While the idea of getting the position of the 'a's and 'c's and pulling the random replacements from that looks promising as being more efficient, especially on long strings, the older working subroutine of works. I'll keep playing with the pos function idea. I might be able to get it to work - thanks.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||