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.txtDave
In reply to Re^2: How to chomp the last new line character from the file
by davido
in thread How to chomp the last new line character from the file
by jojojo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |