加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl是否保证返回一致排序的哈希键?

发布时间:2020-12-15 21:42:06 所属栏目:大数据 来源:网络整理
导读:给出类似的东西 foreach (keys %myHash) { ... do stuff ...}foreach (keys %myHash) { ... do more stuff ...} 如果哈希不被改变,Perl是否保证以一致的顺序迭代密钥? 解决方法 Yes.从 perldoc -f keys 开始: The keys are returned in an apparently rand
给出类似的东西
foreach (keys %myHash) {
   ... do stuff ...
}

foreach (keys %myHash) {
   ... do more stuff ...
}

如果哈希不被改变,Perl是否保证以一致的顺序迭代密钥?

解决方法

Yes.从 perldoc -f keys开始:

The keys are returned in an apparently random order. The actual random order is subject to change in future versions of perl,but it is guaranteed to be the same order as either the values or each function produces (given that the hash has not been modified). Since Perl 5.8.1 the ordering is different even between different runs of Perl for security reasons (see “Algorithmic Complexity Attacks” in 07002).

(强调我的)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读