#! perl -slw use strict; use vars qw[ $a $b ]; use List::Util qw[ reduce ]; my $op = shift @ARGV; my @hasharray; for ( 2 .. @ARGV ) { for my $indices ( Cnr( $_, 0..$#ARGV ) ) { push @hasharray, { LIST=> [ @$indices ], VALUE=> reduce{ my $val = eval "$a $op $b"; } @ARGV[ @$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; }