http://www.perlmonks.org?node_id=1199676


in reply to Splitting a file based on matched conditions

Hi skumar_pm,

I think you could read the file line by line until you meet an End tag and push them in an array. When you reach an End tag, determine in which output file it needs to go, print the array to the proper file handle. Then, empty the array, and read again lines into the array until reaching another End tag, and so on.

With a file containing 100k-lines, it should not be a problem to store the lines of one section (a Start..End chunk) into an memory.

  • Comment on Re: Splitting a file based on matched conditions

Replies are listed 'Best First'.
Re^2: Splitting a file based on matched conditions
by skumar_pm (Initiate) on Sep 20, 2017 at 08:25 UTC
    Thanks for your suggestion.