I need to create something like this:
my $valueref = { 1 => 1, 2 => 2, 3 => 3, 4 => 4 };
Depending on certain conditions, this can be up to 40, or 50 or 60. In each case, these will be consecutive integers, as shown in the example. Having created it, it will never be changed, it is simply transferred to the existing subroutine. Since both keys and values will be consecutive, I could also create a hash using a for loop. I was curious what would be the fastest and / or most efficient way to create a hash? Or, if there is another way, can this be done?
source share