Link to home
Start Free TrialLog in
Avatar of faithless1
faithless1

asked on

Permute Perl Help

Hello,

The following command produces permutations:
perl -MAlgorithm::Permute -lane ' Algorithm::Permute::permute { print "@F" } @F'

i.e. (input)
test1 test2
test3 test4

i.e. (ouput)
test1 test2
test2 test1
test3 test4
test4 test3

This does not produce all variants. Is there a way to adjust the script so it will produce all variants?

output i'm looking for:

test1 test2
test2 test1
test3 test1
test3 test2
test1 test3
test2 test3

etc
ASKER CERTIFIED SOLUTION
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As you only want permutations of only 2 values

perl -MAlgorithm::Permute -lane 'push(@{$X},@F);END{ $p= new Algorithm::Permute($X,2);while(@w=$p->next){print @w} }'