in reply to Split files based on regexp

Have a look at at How can I pull out lines between two patterns that are themselves on different lines? in perlfaq6 for some ideas.