in reply to Re: hash references
in thread hash refferences

Another thing: Unfortunately I can't release the %temp variable every loop iteration, I need to perform it on demand. How I can do it ?

Replies are listed 'Best First'.
Re^3: hash refferences
by moritz (Cardinal) on Aug 21, 2008 at 12:58 UTC
    push @array, { %temp };

    That actually copies the items from %temp into an anonymous hash, and returns its reference.

    See perlreftut and perlref for more details.

      Heh thanks, this is exactly what I did, but somehow it seems not efficient enough.
      What about the following solution:
      Substitute the %temp variable by $tempRef= {} ?
        Yes, you can do that. That way you avoid the copy, and whenever you need a fresh hash you can write $tempRef = {}.
Re^3: hash refferences
by Corion (Patriarch) on Aug 21, 2008 at 12:57 UTC

    You can't. You can store copies of the values in another variable maybe.