|There's more than one way to do things|
splitting an input streamby Anonymous Monk
|on Nov 07, 2003 at 11:27 UTC ( #305274=perlquestion: print w/replies, xml )||Need Help??|
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a unix program lets call it x that processes a file and takes the following parameters:
so a typical invokation could be
this will read foo from line 5 to line 100 inclusive and produce do something with them
I want to call x few times with (--firstLine,--lastLine) like this
(1,1000) (1001,2000) ....
so effectively I am processing foo in chunks of 1000 lines
if I do this and foo has millions of lines the processing time will increase as I progress with the chunks because x is scanning foo to reach firstLine.
I cannot change x and want to write a Perl wrapper for x that reads foo from line 1 to the end and send every chunk of 1000 lines to x and this way I avoid scannig foo multiple times.
Is this possible?
update (broquaint): added formatting
Back to Seekers of Perl Wisdom