Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: how do foreach and while affect an array?

by ysth (Canon)
on Sep 12, 2004 at 19:04 UTC ( [id://390452]=note: print w/replies, xml ) Need Help??


in reply to how do foreach and while affect an array?

Neither. Here is an idiom I occasionally use that does empty an array, though:
my $width = 4; my @in = "a".."z"; while (my @row = splice(@in, 0, $width)) { print "@row\n"; } __END__ Output: a b c d e f g h i j k l m n o p q r s t u v w x y z

Log In?
Username:
Password:

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

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

    No recent polls found