my @array; push @array, "one"; push @array, "two"; push @array, "three"; psuh @array, "four"; my $k=0; my @combos; for(combinations(@array)) { $combos[$k] = join("|",@$_); $k++; } sub combinations { return [] unless @_; my $first = shift; my @rest = combinations(@_); return @rest, map { [$first, @$_] } @rest; }