#!/usr/bin/perl use strict; use warnings; use Algorithm::Loops qw( NestedLoops ); my @products = qw(tshirt pants sweatshirt socks shoes); my %options = ( sizes => [ qw(small medium large extra-large) ], colors => [ qw(red green blue) ], brands => [ qw(foo bar blah asdf) ] ); my @Loops; push @Loops , \@products; push @Loops , $options{$_} for keys %options; my $iter = NestedLoops( \@Loops ); my @combo; print "@combo\n" while ( @combo = $iter->() );