Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: hash refferences

by leonidlm (Pilgrim)
on Aug 21, 2008 at 12:55 UTC ( [id://705782]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://705782]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2026-03-08 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.