#!/usr/bin/env perl use strict; use warnings; use 5.010; use Algorithm::Combinatorics qw(combinations); my @data = qw(a b c d e); # scalar context gives an iterator my $iter = combinations(\@data, 3); while (my $p = $iter->next) { say (join '', @$p); } #### abc abd abe acd ace ade bcd bce bde cde