Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Array Processing

by ioannis (Abbot)
on Oct 09, 2005 at 03:49 UTC ( #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? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2022-12-09 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?