[Perl] split file into odd and even lines

Shlomo Yona shlomo at cs.haifa.ac.il
Sun Oct 6 01:37:23 PDT 2002

On Sun, 6 Oct 2002, Offer Kaye wrote:

> (perl -ne'if($.%2){print}else{warn $_}' a>b)>&c
> My question is- can anyone improve on this solution? I.e., given an input
> file "a" and output files "b" and "c", can you split "a" into the odd and
> even lines into files "b" and "c", in less characters than the above
> solution?

I hope we get better solutions which are more cross-platform, i.e. only use Perl.

Shlomo Yona
shlomo at cs.haifa.ac.il

More information about the Perl mailing list