## Using tye's Algorithm::Loops: NestedLoops( [ 0 .. $#S ], ( sub { [$_+1 .. $#S] } ) x ($K - 1), sub { my @c = @S[@_]; ... } }