The real problem is your infinite loop. Stop that! I suspect ctrl-c is to blame for the truncation. (After having faithfully reproduced the error as shown)
I rewrote the program as follows and got no truncated lines.
@primes = ( 2 );
$testnumber = 3;
open( SAVE, ">primes.dat" );
close SAVE;
while ( 1 ) {
foreach $placeholder ( @primes ) {
if ( ( $testnumber / $placeholder ) =~ /^[+-]?\d+$/ ) {
$testnumber = $testnumber + 2;
next;
}
if ( $placeholder == $primes[-1] ) {
push ( @primes, $testnumber );
open ( SAVE, '>>primes.dat' ) or
die "Couldn't open primes.dat";
print SAVE "$testnumber\n";
close SAVE;
}
next;
}
}
|