#! perl -slw use strict; use vars qw[ $a $b ]; use List::Util qw[ reduce ]; my @indices = map{ Cnr( $_, 0 .. $#ARGV ) } 2 .. @ARGV; my @hasharray; push @hasharray, { LIST=> [ @$_ ], VALUE=> reduce{ $a + $b } @ARGV[ @$_ ] } for @indices; print "@{ $_->{LIST} } : $_->{VALUE}" for @hasharray; exit; sub Cnr{ my( $n, @r ) = shift; return [] unless $n--; for my $x ( 0 .. ($#_ - $n) ) { push @r, map{ [ $_[$x], @$_ ] } Cnr( $n, @_[ ($x+1) .. $#_ ] ) ; } return @r; }