Neat trick, though it won't handle very long strings. (What's with the indentation btw?)
Here's a non-tricky solution:
use Set::CrossProduct;
sub casify {
my @letters = map [ uc $_, lc $_ ], split //, $_[ 0 ];
return(
map join( '', @$_ ),
Set::CrossProduct->new( \@letters )->combinations;
);
}
:-) Of course, it runs much slower, in case that really is a concern…
Makeshifts last the longest. |