#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); } } #### #create objects in my class my $a = param_class->new(\@range_a, $statements); my $b = param_class->new(\@range_b, $statements); $a->loop( $b->loop( &final_sub(%hash) ) );