for my $row (0..3) { for my $col (0..3) { print "Quadrant ", int($row/2),',',int($col/2); print " Element ", $row % 2,',', $col % 2,"\n"; } }