Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Split string after 14 Line Feeds?

by Cody Fendant (Friar)
on Dec 04, 2012 at 11:30 UTC ( #1007067=note: print w/replies, xml ) Need Help??


in reply to Split string after 14 Line Feeds?

Just because this solution hasn't been hinted at yet:

while (<DATA>) { chomp; if ( $. % 14 == 0 ) { print "$_ -- do something here\n"; } else { print "$_\n"; } } __DATA__ line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 line 11 line 12 line 13 line 14 line 15 line 16 line 17 line 18 line 19 line 20 line 21 line 22 line 23 line 24 line 25 line 26 line 27 line 28 line 29 line 30

Don't forget this kind of solution will leave you with extra unprocessed lines whenever the total number of lines isn't a multiple of 14, so wrap those up after you're finished with the loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007067]
help
Chatterbox?
[marto]: hopefully you guys are also well :)
[Corion]: marto: Yeah - I'm looking for a week off in a week, even if it'll be a trip to Amsterdam ;)
[Discipulus]: oh thanks, i'm always at well as the ratchet or bucket
[Corion]: But I'm slowly starting to get into programming again - yesterday I translated my talk for YAPC::E (in Amsterdam) to English, and decided to put my Jekyll-clone to rest for the time being
[Corion]: Discipulus++ # being well is like being earnest
[marto]: hopefully next year I'll be in a position to go to Perly things in Europe :)
[Corion]: Maybe I'll use the Real Jekyll a bit to get a feel for how it actually works, and to get annoyed by it ;)
[Corion]: marto: That would be cool :) There is no kids care at Perly events unfortunately, so it's not entirely family friendly
[Corion]: I think I should define a set of (say) five projects through which I rotate from time to time, just to prevent myself from being bored/annoyed by the problems they get stuck in ;)
[marto]: Corion, not bringing the kids would make it ideal :P

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-07-27 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (404 votes). Check out past polls.