my @set1=(0..7); my @set2=(6..12); my @comb; { local $"=","; @comb = glob"{@set1}-{@set1}-{@set2}-{@set2}-{@set2}"' } print join "\n",@comb;