List::Permutor - Process all possible permutations of a list
use List::Permutor;
my $perm = new List::Permutor qw/ fred barney betty /;
while (my @set = $perm->next) {
print "One order is @set.\n";
}
Make the object by passing a list of the objects to be permuted. Each time that
next() is called, another permutation will be returned. When there are
no more, it returns the empty list.
- new LIST
- Returns a permutor for the given items.
- next
- Returns a list of the items in the next permutation. Permutations are
returned "in order". That is, the permutations of (1..5) will be
sorted numerically: The first is (1, 2, 3, 4, 5) and the last is (5, 4, 3,
2, 1).
- peek
- Returns the list of items which would be returned by next(), but
doesn't advance the sequence. Could be useful if you wished to skip over
just a few unwanted permutations.
- reset
- Resets the iterator to the start. May be used at any time, whether the
entire set has been produced or not. Has no useful return value.
Tom Phoenix <rootbeer@redcat.com>