The Perl built in glob function can do permutations. Here are some examples:
In a permutation, order matters, in a combination, order doesn't matter.
#!/usr/bin/perl
use strict;
use warnings;
my @permutations = glob "{1,2,3}" x 3;
print "@permutations\n";
@permutations = glob "{1,1,7}" x 3;
print "@permutations\n";
@permutations = glob "{a,b,c}{1,2}";
print "@permutations\n";
__END__
extra new lines added for readability
Example1:
111 112 113 121 122 123 131 132 133
211 212 213 221 222 223 231 232 233
311 312 313 321 322 323 331 332 333
Example2:
111 111 117 111 111 117 171 171 177
111 111 117 111 111 117 171 171 177
711 711 717 711 711 717 771 771 777
Example:3 combinations "one from column A", one from column "B".
a1 a2 b1 b2 c1 c2