in reply to Re^2: perl -n seemingly eating a line of input
in thread perl -n seemingly eating a line of input
...but also produces an extra line that is empty.
That is due to your trailing \n and has nothing to do with the parenthesized $_,<> - compare
echo -e '55\n44\n33\n22\n11\n' | perl -n -e '@a = ($_,<>); END{ print +@a; } ' echo -e '55\n44\n33\n22\n11' | perl -n -e '@a = ($_,<>); END{ print @a +; } '
- because echo -e will add a newline to its argument, so there are two of them, and thus an empty line. Use echo -en to suppress that:
echo -en '55\n44\n33\n22\n11\n' | perl -n -e '@a = ($_,<>); END{ print + @a; } '
|
|---|