#! /usr/bin/perl -w
use strict ;
use Data::Dumper ;
$|++ ;
my @my_array = (0, 1, 2, 3) ;
my $my_sub_array_length = 2 ;
my @subsets = () ;
for ( 3 .. 2 ** @my_array ) {
my @digits = reverse split // => sprintf "%b", $_ ;
if ( ( grep { $_ } @digits ) == $my_sub_array_length ) {
my @sub_arr = grep { $digits[$_] } @my_array ;
push @subsets, \@sub_arr ;
}
}
print Dumper( \@subsets ) ;
exit ;
__END__
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche