http://www.perlmonks.org?node_id=412890


in reply to Re^2: newlines in regular expressions
in thread newlines in regular expressions

perl -pi -e 's/^\s*\z//' file.txt deals with blank lines with other whitespace.