in reply to perl -n seemingly eating a line of input
This happens because at the time your loop code @a = <>; is run, there has already been an assignment to $_.
perl -MO=Deparse -n -e '@a = <>; END{ print @a; } ' LINE: while (defined($_ = <ARGV>)) { @a = <ARGV>; sub END { print @a; } ; }
This captures the first line also into @a:
echo -e '55\n44\n33\n22\n11\n' | perl -n -e '@a = ($_,<>); END{ print +@a; } '
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl -n seemingly eating a line of input
by mldvx4 (Hermit) on May 01, 2017 at 12:29 UTC | |
by shmem (Chancellor) on May 01, 2017 at 13:18 UTC | |
by bart (Canon) on May 01, 2017 at 13:00 UTC | |
by Anonymous Monk on May 01, 2017 at 12:46 UTC |