Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Conglomerate of arrays with no duplicates

by Limbic~Region (Chancellor)
on Jan 31, 2004 at 00:03 UTC ( #325458=note: print w/replies, xml ) Need Help??


in reply to Conglomerate of arrays with no duplicates

saberworks,
I believe this does what you want and more:
#!/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->() );
Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://325458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2020-06-04 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?