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