Perl variables will grow as needed. Sometimes it is useful to size an array or hash to accommodate a large number of values, to prevent Perl from repeatedly having to allocate additional space.
# presize a hash: keys(%hash) = 10_000; # size an array: my @array; $#array = 10_000;
Sizing an array to be shorter than it currently is will truncate the array.
TGI says moo
In reply to Re: memory for array
by TGI
in thread memory for array
by vit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |