in reply to How to show all possible replacements?
DB<125> @combis = glob("{a,a1}{b,b1}{c,c1}") => ("abc", "abc1", "ab1c", "ab1c1", "a1bc", "a1bc1", "a1b1c", "a1b1c1 +")
glob takes a string which you can construct by replacing every "a" with "{a,A}" and so on...
see also Re: Substitution of a particular letter in all combinations of positions in word (see inside)
Cheers Rolf
( addicted to the Perl Programming Language)
DB<129> $s = "aabc" => "aabc" DB<130> %r = ( a=>A, b=>B, c=>C ) => ("a", "A", "b", "B", "c", "C") DB<131> $s =~ s/(\w)/{$1,$r{$1}}/g => 4 DB<132> $s => "{a,A}{a,A}{b,B}{c,C}" DB<133> print "$_\n" while glob($s) aabc aabC aaBc aaBC aAbc aAbC aABc aABC Aabc AabC AaBc AaBC AAbc AAbC AABc AABC
|
|---|