Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Scope when initializing with references in a loop

by IraTarball (Monk)
on Dec 06, 2001 at 04:08 UTC ( [id://129816]=note: print w/replies, xml ) Need Help??


in reply to Scope when initializing with references in a loop

BING
The light bulb just went on.

So in the loop I'm assigning an anonymous hash reference. If I change those lines to index to the actual element it behaves like I originally expected.

$array[$i]{val} = rand(time)%3; $array[$i]{one} = \$array[1]{val};
In the original code the anonymous hash is really a new hash, ofcourse, so it's a whole new chunk of data in the array element with a new memory location and everything. But the old data still had references to it from the first two elements of the array so it was not cleared, just no longer available from $array[1]{val}.

I appologize for wasting space here, I think I just needed to throw this out there to get my head working.

Thanks for your time,
Peter C.,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found