in reply to Pick any key from a very large hash

The documentation for each explains how to reset it (hint: third paragraph).

  • Comment on Re: Pick any key from a very large hash

Replies are listed 'Best First'.
Re^2: Pick any key from a very large hash
by FloydATC (Deacon) on Jul 11, 2009 at 22:25 UTC
    Yes, by using keys or values... exactly what I don't want :-)

    -- Time flies when you don't know what you're doing
      "In particular, calling keys() in void context resets the iterator with no other overhead."
        "In particular, calling keys() in void context resets the iterator with no other overhead."
        Unfortunately, that's on the keys entry, and not on the each entry, which it seems to be more relevant to. If I'm using keys without each, why do I care if keys resets the each iterator?

        Granted, a little digging would have found this. And perhaps the OP's avoidance of keys caused the miss.

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

      Or: "it can be reset by reading all the elements from the hash"

Re^2: Pick any key from a very large hash
by psini (Deacon) on Jul 11, 2009 at 22:27 UTC

    I don't think your suggestion is a viable option when the hash contains millions of keys...

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

      Calling keys in void context resets the iterator and does nothing else. The number of keys in the hash is of no import.

        Oh, sorry, I didn't know that.

        Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."