$_ = ($a*($a+1))/2; # calculate last number in triangle my @arr = 1..$_; # list of all numbers in triangle my $i; while(@arr) { $i++; my $format = ' %' . y///c . 'd'; # y///c is a short version of length($_) # originally in "@{[2 + 2]}" form -- which # creates, dereferences and stringifies # a one element array ref my @row = splice(@arr,0,$i); # take $i elements off the front of @arr printf $format x $i . $/, @row; # print the whole row, instead of using an # explicit loop like the rest of us }