in reply to for loop

This problem looks like homework, but...

I'd start adding use strict; use warnings; at the begin of your code, then making all your vars lexical (my).

Your code prints a single block from the input matrix, you obviously could replicate the code for each of the blocks, but it is not the best way. Perhaps you should parametrize your loops e.g. for(my $row = 2*$blockRow; $row < 2*$blockRow+2; $row++)

So you have a code, that you could put in a sub, that can print any of the blocks you require; then another couple of for loops can be used to print all the blocks.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."