What's the safest way to iterate through the keys of a Perl hash?

后端 未结 9 957
情深已故
情深已故 2020-12-22 20:31

If I have a Perl hash with a bunch of (key, value) pairs, what is the preferred method of iterating through all the keys? I have heard that using each may in s

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 21:12

    I always use method 2 as well. The only benefit of using each is if you're just reading (rather than re-assigning) the value of the hash entry, you're not constantly de-referencing the hash.

提交回复
热议问题