当Perl 5.8.1出来时它增加了
hash randomization.当Perl 5.8.2出来时,我想,它除去了哈希随机化,除非存在环境变量(PERL_HASH_SEED).现在好像我被严重误认为
PERL_HASH_SEED=$SEED perl -MData::Dumper -e 'print Dumper{map{$_,1}"a".."z"}'
无论$SEED的值如何,始终都会使用相同的键排序.
解决方法
见
Algorithmic Complexity Attacks:
In Perl 5.8.1 the hash function is randomly perturbed by a pseudorandom seed which makes generating such naughty hash keys harder. […] but as of 5.8.2 it is only used on individual hashes if the internals detect the insertion of pathological data.
因此,只有当perl检测到需要时,才会发生随机化.