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--fileName: just a text file name --firstLine: integer --lastLine: integer
this will read foo from line 5 to line 100 inclusive and produce do something with themx --fileName=foo --firstLine=50 --lastLine=100
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