From: Nikola Janceski <[EMAIL PROTECTED]> > I am wondering how undef works. > > I know that undef will undefine a variable if used like > undef($scalar); I also know that it doesn't actually free up the > memory but tells Perl that it's now available to be recycled for other > data. > > but what about nested data (ie. hashes of hashes, arrays of arrays, > etc.). if $ref is a reference to a nested structure (let's say a hash > of hashes). will - undef $ref; > - undefine the enitre nested data structure if no other variables > contain > references to any part of it? (assuming no cyclical references)
Perl as usual does what you need. If there are no cyclic references the whole structure will be garbage collected (freed) and the memory will be reused. To create even cyclic references that may be garbage collected use the weakref() function from Scalar::Util. I'm not feeling like explaining garbage collection (I know how it works, but would screw the explanation.) so please try to find something on "reference counting garbage collection". Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
