i think i got this from one of merlyn's pages, so if you like it, the thanks go to him. i'm at a loss to explain why this function or one like it isn't in one of the algorithm modules (but i don't think it is; yet).
sub combinations {
return [] unless @_;
my $first = shift;
my @rest = combinations(@_);
return @rest, map { [$first, @$_] } @rest;
}