use Algorithm::Permute; my $p = new Algorithm::Permute(['a'..'e']); while (@res = $p->next) { print join(", ", @res), "\n"; }