[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

Nice.
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
http://cs.haifa.ac.il/~shlomo/




More information about the Perl mailing list