in reply to Re: How to chomp the last new line character from the file
in thread How to chomp the last new line character from the file

You don't need ($x) when you have ($.). perlvar.

But all that's too much fuss when you have eof. There's no need to keep track of what constitutes the last line number.

You could do it as a one-liner like this:

perl -pi.bak -e 'chomp if eof' file.txt

Dave