[Israel.pm] Arrays

Peter Gordon peter at pg-consultants.com
Sun Aug 19 23:14:48 PDT 2007


I have a number of arrays

@c = qw[1 2 3 ]
@d = qw[4 5 6 ]
@e = qw[7 8 9 ]


and I want to find all possible combinations of all elements
eg 1,4,7   1,4,8   1,4,9,
   1,5,7   1,5,8,  1,5,8

This is the code:

for $c (@c) {
    for $d (@d) { 
	for $e (@e) { 
	    print "$c $d $e\n" ;
	} 
    } 
} 
    
Is there a package which iterates over arrays? 

Thanks,

Peter




More information about the Perl mailing list