my $iter = combinations( $k => \@vertices ); SUBSET: while ( my @subset = $iter->() ) { my $pairs = combinations( 2 => \@subset ); while ( my @pair = $pairs->() ) { next SUBSET unless @pair is an edge in the graph; } print "@subset is a $k-clique\n"; } #### if ($string =~ /$regex/x) { print join(" ", map $$_, 1..$k), "\n"; } #### $regex .= '(?{ print join(" ", map $$_, 1..$k), "\\n" })(?!)'; $string =~ /$regex/x; #### 5 6 9 2 3 4 1 3 4 1 2 4 1 2 3