sub ton_pascal { my $rows = shift; my $last_row = [ ]; my $this_row = [ 1 ]; last unless ($rows > 0); print "1\n"; for (my $i = 1; $i < $rows; ++$i) { $last_row = $this_row; $this_row = [ 1 ]; for (my $j = 1; $j < $i; $j++) { push(@$this_row, $last_row->[$j - 1] + $last_row->[$j]); } push(@$this_row, 1); print join(' ', @$this_row) . "\n"; } }