in reply to How do I split a file into separate sections?
That will build a hash of arrays with the headers as keys. Things you might want to change are as follows:while ($data =~ s!(TI|AU|JN):(.*)?!!s) { push @{$sections{$1}}, $2; }
- With the /s modifier on the regex, . will match newlines. You may not want this (but it makes the regex much more complicated)
- You may not want a hash of arrays. Remove the @ and use the .= operator
- You may want to match a newline after the colon.
In Section
Seekers of Perl Wisdom