Jump to content
Sign in to follow this  

"un-defining" ?

Recommended Posts


i am searching for a way of easily undefining or "nul"-ling a variable


Perl's undef function

The 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>;

    you can later do

    undef (@count);

    to free up memory resources. However


    is best for undefining a single element of a hash array. For example, if you load $hasharray{'element10'} you can do

    undef $hasharray{'element10'}

Share this post

Link to post
Share on other sites

The only way I know of doing that is to use:

$var = ""
Edited by TheCuz

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.