use strict; my $arrayref; { #create a closure for @array my @array = qw(zero one two three); $arrayref = \@array; } # @array is out of scope but @array's data still there print $arrayref->[1],"\n"; # prints "one" $arrayref->[4] = $arrayref; # circular reference. $arrayref = 1; # memory leak ! # @array's memory is never freed # until program ends!
--
flounder
In reply to Re: Re: Storing arrays as object variables
by flounder99
in thread Storing arrays as object variables
by Basilides
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |