in reply to Populating Hash of hashes

If you have a variable number of fields as a hash with variable number of elements, you can iterate over the list, processing the fields one at a time.

use strict; use warnings; use Data::Dumper; my %fields = ( f1 => [ 1, 2 ], f2 => [ 3, 4, 5 ], f3 => [ 6, 7 ], ); my @combinations = ( {} ); foreach my $field (keys %fields) { my @tmp; foreach my $value (@{$fields{$field}}) { foreach my $c (@combinations) { push(@tmp, { %$c, $field => $value } ); } } @combinations = @tmp; print "Intermediate:\n" . Dumper(\@combinations); } print "Final:\n" . Dumper(\@combinations);

This program does not produce a hash of hashes, which you said you needed, but you may be able to adapt it to produce the data structure you need. It does demonstrate how a program can iterate over variable data similar to your field definitions.

You might find an introduction to programming helpful. For self study, there are pointers to many resources for learning Perl programming in Where and how to start learning Perl.