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


in reply to How do I split a file into separate sections?

while ($data =~ s!(TI|AU|JN):(.*)?!!s) { push @{$sections{$1}}, $2; }
That will build a hash of arrays with the headers as keys. Things you might want to change are as follows: This all depends on your data. Personally, I'd use split in a heartbeat.