Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hash merging method affected in Perl 5.18+ by hash order randomization?

Tags:

merge

hash

perl

According to the answer to this question, merging two hashes in Perl 5 can be done either with:

%newHash = (%hash1, %hash2); %hash1 = %newHash;

or:

@hash1{keys %hash2} = values %hash2;

On the other hand, Perl 5.18 will introduce per process hash randomization.

Will the second method still be correct to use in Perl 5.18?

like image 901
andrefs Avatar asked Jan 22 '13 17:01

andrefs


1 Answers

After reading through Re^2: Hash order randomization is coming, are you ready?, the answer is yes. As before, keys, values and each will produce the same sequence iterating through the hash inside the same process if the hash isn't changed in between.

like image 137
Perleone Avatar answered Oct 19 '22 17:10

Perleone