for my $i (1..$depth-1) { my $val = 1 + 2*$i; push @$loop, sub {[$_+1..$val]}; }