[Perl] split file into odd and even lines

Shlomo Yona shlomo at cs.haifa.ac.il
Sun Oct 6 06:06:31 PDT 2002

On Sun, 6 Oct 2002, Mikhael Goikhman wrote:

> -p works this way. The input line is passed in $_ and the output line is
> read from $_ as well. This makes it easy to filter the input line using
> s/// or similar regexps.
> So, in the first command above, the input (odd) line is not changed, just
> the even line is read and dismissed. In the second line it is vice versa,
> the original (odd) line is ignored and replaced with the even one.
> See "man perlrun" or "perldoc perlrun" to learn about how "-p" works.

This is all great - but the result of <> also gets into $_
or at least should be implicitly.

I wonder why <> is not assigned to the $_ which get printed by the -p

Shlomo Yona
shlomo at cs.haifa.ac.il

More information about the Perl mailing list