Next | Program Repair Shop | 265 |
We now have:
sub printout { for my $i (0 .. $#{$chain[1]}){ my @chars; for (@chain) { next unless defined; if ($ct_scanout) { $_->[$i] =~ tr/01/LH/; } else { $_->[$i] =~ tr/X/0/; } push @chars, $_->[$i]; } print OUTFILE $ct_scanout ? "\n(ct_so\n" : "\n(ct_si $ct_si{tdi}\n", join("", @chars), "\n )"; } }
We are still making two passes:
One pass to construct @chars in the for loop
One pass to turn it into a string in the join
If @chars were a string, we would not have to join it
Next | Copyright © 2002 M. J. Dominus |