#!/usr/bin/perl use warnings; use strict; use Algorithm::Permute; my @a=qw/ A B C /; # You can create r of n objects permutation generator, where r <= n my $p=new Algorithm::Permute(@a,2); while (@res = $p->next) { print join(", ", @res), "\n"; } exit; # Script ends here