proper way:

@an_array = ();

or

undef @an_array; # doesn't really free up the memory it used but the array
is uninitialized

-----Original Message-----
From: Barry Kingsbury [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 10:31 AM
To: [EMAIL PROTECTED]
Subject: Reinitializing an Array


I have an array that I wish to reuse. Before I reuse it, I want to clear out
all

elements. Both of the following seem to work:

    @an_array = "";

and

    $#an_array = -1;

I then go on to do something like:

    foreach (@foo_array) {
       push (@an_array, $_);
    }

Neither seems completely correct although I like the second. Is the second
legal
and
portable or did I just luck out?

Is there a better way?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to