in reply to matching and writing multiple line blocks

I have three sets of repeating blocks of data. Each one has a start word and an end word. I'm showing these and the sizes below:
Block 1
Start: Experiment 
End  : Reagent Lot
Size : 10 lines followed by one blank line
Block 2
Start : Algorithm Parameters
End   : FCMax
Size  : 5 lines followed by one blank line
Block 3
Start : Experiment
End   : Pixels
Size  : 8 lines followed by one blank line

So what happens is for four sets of data, there will be four sets of block 1, followed by four sets of block 2, followed by 4 sets of block 3. Followed by more stuff I was going to try and figure out before bothering you kind monks again :).

I had already thought out a short cut - all blocks are the same size, so I simply needed to know how many experiments there were, say 4, and then count down through each of the blocks as I already know the order and size of each. So some simple addition and division could get me where I needed to be.

What I was pretty clueless about was how to match the first block and somehow write it to an output file, repeat for all the Block 1s, then do the same for all the Block 2, etc. I do want to learn how to do multiple line extractions of text - it is a good general technique and I can use it for other stuff - Thank you!

Now I'll go play with your suggestions...
MadraghRua
yet another biologist hacking perl....

  • Comment on Re: matching and writing multiple line blocks