use strict; use warnings; use Algorithm::Combinatorics qw(combinations); my $strings = [qw(Word1 Word2 Word3 Word4)]; my $iter = combinations($strings, 2); while (my $c = $iter->next) { print "@$c\n"; }