$N = 6; for $i (reverse(1..$N)){ for $j (1..$i){ print "$j,",$j+1-$i+$N,","; } print "\b\n"; }