in reply to Combinations of array?

Algorithm::Combinatorics
use warnings; use strict; use Data::Dumper; use Algorithm::Combinatorics qw(combinations); my @array = qw(A B C D); for (1 .. 4) { my @combos = combinations(\@array, $_); print Dumper(\@combos); } __END__ $VAR1 = [ [ 'A' ], [ 'B' ], [ 'C' ], [ 'D' ] ]; $VAR1 = [ [ 'A', 'B' ], [ 'A', 'C' ], [ 'A', 'D' ], [ 'B', 'C' ], [ 'B', 'D' ], [ 'C', 'D' ] ]; $VAR1 = [ [ 'A', 'B', 'C' ], [ 'A', 'B', 'D' ], [ 'A', 'C', 'D' ], [ 'B', 'C', 'D' ] ]; $VAR1 = [ [ 'A', 'B', 'C', 'D' ] ];

Replies are listed 'Best First'.
Re^2: Combinations of array?
by dagwood00 (Initiate) on Jun 09, 2012 at 01:47 UTC
    This worked for what I needed. Thanks for you help!