[EMAIL PROTECTED] (Scott Alexander) wrote:
>in my code I have
>
>my @upper_id ;
>
>during the code I pass the array by reference to a sub routine and push
>values onto it.
>
>push @{$upper_id}, $row[0] ;
>
>Some of my code I have arrays of strings or ints.  I might add 100 or
>more items to each array. The strings could be 50 characters long.  What
>happens to the array at the end?  Should I have a
>
>undef @upper_id ;
> at the end ?
>
>If I don't have this does it mean the array just stays in memory until
>the child is stopped?

That all depends on where the original array declaration is.  If it's in
some block whose scope is limited to the request, it'll get properly
cleaned up.  If it's got file-scope or something undesirable like that,
you'll have to clean it up manually - or better, just fix its scoping.

BTW, I usually prefer '@array=();' to 'undef @array;', because I like to
let Perl handle the memory allocation/deallocation.  If memory is tight
though, then I suppose you'll do what you have to do.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  [EMAIL PROTECTED]                            The Math Forum

Reply via email to