Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@postwait
Created February 18, 2014 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postwait/9073497 to your computer and use it in GitHub Desktop.
Save postwait/9073497 to your computer and use it in GitHub Desktop.
sub combo {
my $hash = shift;
my %hashcopy = %$hash;
my $list = shift || [];
my $s = shift || {};
my @k = (keys %hashcopy);
if(scalar(@k) == 0) { push @$list, $s; return; }
my $arr = $hashcopy{@k[0]};
delete $hashcopy{@k[0]};
for my $v (@$arr) {
my %copy = %$s;
$copy{@k[0]} = $v;
combo(\%hashcopy, $list, \%copy);
}
return $list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment