in reply to For- loop increment not passing to inner block

Could you possibly have meant:

for (my $i = 0; $i <= 4; $i++) { my $j=0; while (my $line = readline(SORTD)) { $j++; my $number = substr($line, $j*2, 2); } }

Just a wild guess of course but when you wanted the counter of the inner loop to vary, you probably meant to have a different variable.

(There are nicer ways of writing this but I wanting the changes to be obvious.)