Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Breaking output lines into N-element chunks

by talexb (Chancellor)
on Apr 11, 2002 at 16:53 UTC ( [id://158360]=note: print w/replies, xml ) Need Help??


in reply to Breaking output lines into N-element chunks

If you use splice you'll get something that works OK:
my @a = qw/v0 v1 v2 v3 v4 v5/; while ( $#a >= 0 ) { print "Directive: " . join ( " ", splice ( @a, 0, 4 ) ) . "\n"; }
The groovy part about this is that if the array's empty, nothing prints.

--t. alex

"Here's the chocolates, and here's the flowers. Now how 'bout it, widder hen, will ya marry me?" --Foghorn Leghorn

Update Well, mdillon remembered the map munge() part and I didn't. ++ to him.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found