#!perl use strict; use warnings; { # braces for localization of $/ local $/ = '

'; # end of record is now

print scalar ; # first chunk contains everything before first

tag, just print for () { s@([\d\D]*?

)@ my $var = $1; $var =~ s!\n! !g; $var @e; # substitute newlines by spaces before the closing

tag print; } } __DATA__ This is to test. this is to test

This is to test. This is to test

This is to test. This is to test

This is to test. this is to test