in reply to Array Processing

There is little need to use for, while, or recursion to delete all elements of @a. We could instead use the undef operator:
my @a= (1..5) ; undef @a;
And since the range operator is evaluated in array context, we could also drop the parens:
my @a = 1..5; undef @a;

Replies are listed 'Best First'.
Re^2: Array Processing
by EvanCarroll (Chaplain) on Oct 09, 2005 at 17:35 UTC
    Same Effect:
    perl -le'@_=1..5;undef @_;print scalar@_;' 0 perl -le'@_=1..5;@_=();print scalar@_;' 0


    Evan Carroll
    www.EvanCarroll.com