$ perl -pe'eof&&chomp' file | nextprocess $ perl -0pe's/\n\Z//' file | nextprocess