he undefine function (undef) undefines a scalar variable, an array element or an entire array. If you inhale a large table into an array, undef can be used to clear the array and free up system memory. For example:
open(COUNT,"/path/to/count/file.txt") || die "Can't Open Count Data File: $!\n"; @count = <COUNT>; close(COUNT);you can later doundef (@count);to free up memory resources. Howeverundefis best for undefining a single element of a hash array. For example, if you load $hasharray{'element10'} you can doundef $hasharray{'element10'}
to completely remove the element from the array. Just don't do this if you are iterating over the hash.
undefdoes have two other uses that are fairly arcane.
No comments:
Post a Comment