Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Array Processing

by ioannis (Abbot)
on Oct 09, 2005 at 03:49 UTC ( [id://498503]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://498503]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found