Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Conglomerate of arrays with no duplicates

by Limbic~Region (Chancellor)
on Jan 31, 2004 at 00:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://325458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found