# then go thorough $hash_F2_2 and that has the key (origin) # and max as value and make a multivalue hash as follows: for my $k (sort keys %hash_F2_2){ my $v = $hash_F2_2{$k}; #print RESULTS "$k\t$v\n"; for (my $i=1; $i <= $v; $i++){ push (@{$hash_F2_3{$k}}, $i); # this hash (%hash_F2_3) is the hash of origins and PIPs from 1 to max } } #### # then go thorough $hash_F2_1 and that has the key (origin) # and make a multivalue hash as follows: my %hash_F2_3; for my $k ( sort keys %hash_F2_1 ) { #print RESULTS "$k\t$hash_F2_1{ $k }\n"; @{ $hash_F2_3{ $k } } = 1 .. max @{ $hash_F2_1{ $k } }; # this hash (%hash_F2_3) is the hash of origins and PIPs from 1 to max }