Another approach:
my $str = 'ABC---'; my $dash = $str =~ tr/-//d; my %combo = ($str => 1); %combo = map { my $x = $_; map {$x =~ s/.{$_}\K/-/r, 1} 0..length; } keys %combo for 1..$dash; say for reverse sort keys %combo; __END__ ABC--- AB-C-- AB--C- AB---C A-BC-- A-B-C- A-B--C A--BC- A--B-C A---BC -ABC-- -AB-C- -AB--C -A-BC- -A-B-C -A--BC --ABC- --AB-C --A-BC ---ABC
In reply to Re: combinations of given string
by Anonymous Monk
in thread combinations of given string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |