[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Cleaning out arrays




Sveinbjorn Thordarson wrote:

> I need to clean out an array, as in wipe every single value, and
> pop/shift just aren't doing what I want.  I want the array to be as if
> it had never contained any values...fresh and new. =)  How do I go about
> doing that?

Assign your array an empty list (third line):

   @MyList = (1, 2, 3);
   print "\n(1.) ", join "  /  ", @MyList;
   @MyList = ();
   print "\n(2.) ", join "  /  ", @MyList;

Or if you use it in a sub, then declare it as "my",
and it will be empty each time the sub is invoced:

sub MyProcedure  {
   my @MyList;
   ## ....
   }

Detlef Lindenthal <detlef@lindenthal.com>


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org