Given that undef is designed to do that job, I wonder why you would use anything else?
- @a = (); clears the scalars and sets the notional size as reported by scalar @a or $#a to zero, but it does not release or reduce the basic AV. Thus it hangs on to some memory even though the array is 'empty';
use Devel::Size qw[ total_size ];;
@a = 1 .. 1e6;;
print total_size( \@a );;
32000176
@a = ();;
print total_size( \@a );;
8000176
- splice @a; has the same, hang-on-to-some-of-it effect as @a = ();
@a = 1 .. 1e6;;
print total_size( \@a );;
32000176
splice @a;;
print total_size( \@a );;
8000176
- undef however, does a proper job and releases (almost) all the associated memory back to the process pool:
@a = 1 .. 1e6;;
print total_size( \@a );;
32000176
undef @a;;
print total_size( \@a );;
176
All it retains the essential head structure.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.