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 complete
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: Reinitializi
Barry Kingsbury wrote:
>
> 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 = "";
This does not clear out all elements, it assigns one element to
@an_array with the value of "".
> and
>
> $#
you can always set it to undef also:
@an_array=undef;
---
Luke Davison
[EMAIL PROTECTED]
- Original Message -
From: "John W. Krahn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 13, 2002 2:59 PM
Subject: Re: Reinitializing an Array
&
--Original Message-
From: luke
To: [EMAIL PROTECTED]
Sent: 3/13/02 3:35 PM
Subject: Re: Reinitializing an Array
you can always set it to undef also:
@an_array=undef;
---
Luke Davison
[EMAIL PROTECTED]
- Original Message -
From: "John W. Krahn" <[EMAIL PROTECTED]>
To
[message rearranged chronologically - please don't top-post]
Luke wrote:
>
> From: "John W. Krahn" <[EMAIL PROTECTED]>
>
> > Barry Kingsbury wrote:
> > >
> > > 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: