To answer your question about resetting a hash to access one of its key value pairs...that could be interpreted in a variety of ways.
Restting a hash i usually interpret as:
%my_hash = ();
Which would delete all the key-value pairs, which i highly doubt is what you want.
You are probably thinking of the key iterator needing to be reset. When you traverse the keys in a hash using
keys,
each, or
values, the hashes internal iterator is used to keep track of what key to return next. There is only 1 iterator in a hash, not 1 for each type of operation. But, generally you dont need to worry about this if you are using
keys or
values, becuase they always iterate through the hash all at once, although it may not look like that in your program. (more details can be found in various docs)
When you use
each though, only the *next* key / value pair is returned, and the iterator is somewhere in the *middle* of the key list. So if you have a loop using
each and it exits before traversing the entire hash, the iterator will not be put back to the start of the key list. This is the only time that you would generally need to reset the iterator. One way to do this is simply:
keys %myhash;
That may be more info than you wanted. But accessing a key or value in a hash has nothing to do with the key iterator.
That said, if you do add or delete keys during a loop, you may get some unexpected behaviour in the loop.