in reply to Garbage Collection and undef

There are some comments on Memory.

No you don't redeclare the variable. IE my. Unless it's in a different scope.

also I think undef and assigning the array to an empty array as the same operation. (Someone will probably correct me if I'm wrong.)

"Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


OSUnderdog

Replies are listed 'Best First'.
Re^2: Garbage Collection and undef
by duff (Parson) on Oct 17, 2004 at 04:21 UTC
    I think undef and assigning the array to an empty array as the same operation. (Someone will probably correct me if I'm wrong.)

    You're wrong :-) undefing the array will free the memory associated with the array back to the arena to be reused later. @array = (); does not free the memory used by the array. This has the primary advantage of saving allocation later if you're continually putting stuff in the array then clearing it. (i.e. perl doesn't need to regrow the array each time you put stuff in it after it has been cleared)

    But ... both of them make the array empty, so if that's all you meant by "the same operation", then you're okay. ;-)