#I have some variables, and some ranges. #really it's in a tied hash somewhere. my %hash = { #pretend that this is my tied hash a => "20", b => "yes", q => "1e-14" }; my @range_a = (1..20); my @range_b = ("yes", "no"); #each variable of interest has a foreach loop # to go through the values in it's range foreach my $a (@range_a){ $hash{a} = $a; #other variables may be involved. my $seed = srand($a + 42); my $randomness = rand($seed); #or a function func_1(%hash); foreach my $b (@range_b){ $hash{b} = $b; my $foo = $b + $a; #Then, at the innermost level, do something #There could be any number (probably below 20) # of these loops. my $result = end_func(%hash); } }