|go ahead... be a heretic|
Read File In Four-Line Chunks / TMTOWTDI / Golfby Cody Pendant (Prior)
|on Jun 06, 2003 at 06:52 UTC||Need Help??|
I asked this question on the chatterbox, and it provoked a flurry of interesting responses -- seven or eight different ones from tye alone! -- so I thought I might post it and see what monks came up with.
Problem -- I have a file. I want to read it in four-line chunks, because it goes
and so on.
Solution? My first one was to slurp and then do like this:
which makes me wince to look at it.
Now I'm going to do it with the much more Perlish
Interesting bit: all these solutions are based on whole-file slurpage (fine for me, very small files) but the interesting solutions were the ones which didn't do that, the ones for actually reading the file itself.
Any interesting solutions? (Stands back...)
Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.