In perl, if I have a hash
my %ranges = ( '--tic' => [ 0, 1, 2 ], '--threads' => [ 8, 16 ], '--level' => [ 10, 20 ] );
how can i generate an array from all combinations e.g.
--level 10 --threads 8 --tic 0 --level 10 --threads 8 --tic 1 --level 10 --threads 8 --tic 2 --level 10 --threads 16 --tic 0 --level 10 --threads 16 --tic 1 --level 10 --threads 16 --tic 2 --level 20 --threads 8 --tic 0 --level 20 --threads 8 --tic 1 --level 20 --threads 8 --tic 2 --level 20 --threads 16 --tic 0 --level 20 --threads 16 --tic 1 --level 20 --threads 16 --tic 2
There can be any number of hash entries, and each entry can contain any number of elements in an array of values. The order of the output array does not matter, you just need to have 1 element for each combination, 3 * 2 * 2 = 12 in this case, but it can be any number.
I think some combination of splicing, card and foreach should work, but I am not good at it to find it.
source share