Hi,
I'm starting to pull my hair out over this apparently simple problem: how to get rid of the trailing empty lines in a text file, no matter how many there are, while keeping a final carriage return? I can achieve what I want with sed but would like to do it in perl. Here's the sed one-liner:
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' /tmp/file.txt -i