http://www.perlmonks.org?node_id=885604


in reply to Re: Tie::File is driving me crazy
in thread Tie::File is driving me crazy

The actual working script doesn't have that in it. THIS is the real popfileb:

sub popfileb { my $countgen0 = 0; foreach my $dlp ( 0 .. $LST - 1 ) { foreach my $yb ( $dr0[$dlp] .. $dr1[$dlp] ) { my $countgen = $countgen0++ - $dr3[$dlp]; my $change = $countgen * $dr4[$dlp]; my $incrs = int( $dr2[$dlp] + $change ); my $incrsdel = int( $dr5[$dlp] + abs $change ); my $chntot = $incrsdel + $incrs; foreach my $xb ( 0 .. $total ) { #set first row; if ( $yb == 0 ) { if ( $xb < $dr2[$dlp] ) { substr $aod[0], $xb, 1, 'a'; } else { substr $aod[0], $xb, 1, 'n'; } } #set increasing rows; elsif ( $dr4[$dlp] >= 0 ) { if ( $xb < $dr5[$dlp] + $incrs ) { if ( substr( $aod[ $yb - 1 ], $xb, 1 ) eq 'd' +) { substr $aod[$yb], $xb, 1, 'd'; } else { substr $aod[$yb], $xb, 1, 'a'; } } else { substr $aod[$yb], $xb, 1, 'n'; } } #set decreasing rows; else { if ( $xb <= $chntot ) { if ( substr( $aod[ $yb - 1 ], $xb, 1 ) eq 'd' +) { substr $aod[$yb], $xb, 1, 'd'; } elsif ( substr( $aod[ $yb - 1 ], $xb, 1 ) eq ' +a' ) { substr $aod[$yb], $xb, 1, 'a'; } else { substr $aod[$yb], $xb, 1, 'n'; } } else { substr $aod[$yb], $xb, 1, 'n'; } } } #set random decreased cell; if ( $dr4[$dlp] < 0 ) { #pre-populate deletion array; my @delarray = ( 0 .. $chntot ); fisher_yates_shuffle( \@delarray ); my $cndiea = 0; foreach my $del ( 0 .. $chntot ) { if ( defined substr( $aod[$yb], $del, 1 ) && substr( $aod[$yb], $del, 1 ) eq 'd' ) { $cndiea++; } } my $cnr = $cndiea; for my $xd ( 0 .. $chntot ) { my $xda = $delarray[$xd]; if ( defined substr( $aod[$yb], $xda, 1 ) && substr( $aod[$yb], $xda, 1 ) eq 'a' && $cnr < $incrsdel ) { substr $aod[$yb], $xda, 1, 'd'; $cnr++; } } } } } return; }

It's now working.