Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Split string after 14 Line Feeds?

by johngg (Abbot)
on Dec 03, 2012 at 23:47 UTC ( #1006966=note: print w/replies, xml ) Need Help??

in reply to Split string after 14 Line Feeds?

Another way would be to accumulate the chunks as you read the file.

$ for i in `seq 1 13`; do echo Line $i; done | perl -e ' while ( not eof STDIN ) { my $buf; $buf .= $_ for map { eof STDIN ? () : scalar <> } 1 .. 5; print $buf; print q{+} x 10, qq{\n}; }' 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 ++++++++++ $

I hope this is of interest.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006966]
[huck]: the first one works just fine from the command line but requires editing
[huck]: but neither will handle autoloads
[Lady_Aleena]: huck, I was thinking more along the lines of just getting all my .pm files, iterating over them, and making a big ol' hash or something.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-05-27 00:12 GMT
Find Nodes?
    Voting Booth?