What have you tried so far?
When you read an empty line, you can't know yet whether to print it. So you need something along the lines of
my $newlines = 0; while (<$file>) { if (/^$/) { $newlines++; } else { print "\n" x $newlines; print; $newlines = 0; } }
(untestested).
update: closed regex, ww++.
In reply to Re: How to remove newline characters at the end of file
by moritz
in thread How to remove newline characters at the end of file
by ashokpj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |