my $c = 0; my @partitions = map { [$c, $c += $_] } @widths; #### [0, 2] [2, 8] [8, 13] [13, 20]