[Perl] split file into odd and even lines

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

On Sun, 6 Oct 2002, Mikhael Goikhman wrote:

>   perl -pe'<>'<a>b
>   perl -pe'$_=<>'<a>c

I was surprised by the behaviour of <> with the -p switch.
It seems that in the first line, the result of <> is ignored by the -p switch
although it is saved in $_ (or so I though).

In the 2nd line, it seems that the exmplicit assignment into $_ run-over the
line read by -p.

I would love some explenation of how this works.

Shlomo Yona
shlomo at cs.haifa.ac.il

More information about the Perl mailing list