use Algorithm::Loops qw( NextPermute ); my @list = sort qw( a b c ); do { print(join(', ', @list), "\n"); } while (NextPermute(@list));