in reply to Re: Optimization, side-effects and wrong code
in thread Optimization, side-effects and wrong code

Thanks for the tip. I guess it should be printed in bold in each's manpage.

ESC[78;89;13p ESC[110;121;13p

  • Comment on Re^2: Optimization, side-effects and wrong code

Replies are listed 'Best First'.
Re^3: Optimization, side-effects and wrong code
by BrowserUk (Patriarch) on Sep 29, 2004 at 19:08 UTC

    It is noted in the POD for keys:

    As a side effect, calling keys() resets the HASH's internal iterator, see each. (In particular, calling keys() in void context resets the iterator with no other overhead.)

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      I had the misfortune of getting caught out by this the other day. I decided to call 'keys' inside a while (each) loop... this reset the pointer, causing an infinite loop :/