use strict; use warnings; my $record = ''; while (defined (my $line = )) { chomp $line; if ($line =~ /^\S|:$/ && length $record) { print "$record\n"; $record = ''; } $record .= ' ' if length $record; $record .= $line; } print "$record\n" if length $record; __DATA__ Into the little hill 2-osainen lyyrinen tarina sopraanolle, altolle seka viidelletoista soittajalle 1. OSA (01-05) /20:28: 01 1. The crowd (Kill them they bite, kill them they steal -) /0:50. 02 2. The minister and the crowd (The minister greets the crowd -) /2:50. 03 3. The crowd (Kill them they bite, kill them they steal -) /1:42. 04 4. The minister and the stranger (Night comes but not sleep -) /8:33. 05 5. Interlude - Mother and child (Why must the rats die, Mummy? -) /6:33. 2. OSA (06-08) /16:34: 06 6. Inside the minister's head (Under a clear sky, the minister steps from the limousine -) /3:43. 07 7. The minister and the stranger (His head lies on his desk, between the family photograph -) /5:52. 08 8. Interlude - Mother(s) and child(ren) (Each cradle rocks empty -) /6:59. 3. OSA BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH (09-10) /14:14: 09 9. Another very long stupid song title to be used as yet another dumb example /6:66. 10 10. Last fictive song title /6:66. #### Into the little hill 2-osainen lyyrinen tarina sopraanolle, altolle seka viidelletoista soittajalle 1. OSA (01-05) /20:28: 01 1. The crowd (Kill them they bite, kill them they steal -) /0:50. 02 2. The minister and the crowd (The minister greets the crowd -) /2:50. 03 3. The crowd (Kill them they bite, kill them they steal -) /1:42. 04 4. The minister and the stranger (Night comes but not sleep -) /8:33. 05 5. Interlude - Mother and child (Why must the rats die, Mummy? -) /6:33. 2. OSA (06-08) /16:34: 06 6. Inside the minister's head (Under a clear sky, the minister steps from the limousine -) /3:43. 07 7. The minister and the stranger (His head lies on his desk, between the family photograph -) /5:52. 08 8. Interlude - Mother(s) and child(ren) (Each cradle rocks empty -) /6:59. 3. OSA BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH (09-10) /14:14: 09 9. Another very long stupid song title to be used as yet another dumb example /6:66. 10 10. Last fictive song title /6:66.