in reply to How to Print Every Other Line

Since you already have your answer, this is a great question for golfing! How about:
perl -pe'eof||<>'

Update: Fixed bug found by BrowserUK. Thanks japhy!

Update: A few people have asked to see the original, buggy version. It was simply perl -pe'<>'.

Replies are listed 'Best First'.
Re^2: How to Print Every Other Line
by japhy (Canon) on Jun 30, 2004 at 21:04 UTC
    This fixes the problem stated with your code: perl -pe'eof||<>'
    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
Re^2: How to Print Every Other Line
by BrowserUk (Patriarch) on Jun 30, 2004 at 20:49 UTC

    Work great for files containing an even numbers of lines, but hangs waiting for more input if the file has an odd number.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
Re^2: How to Print Every Other Line
by Jasper (Chaplain) on Jul 01, 2004 at 14:24 UTC
    perl -pe '<>' < input
    I didn't see the original one that hung on odd numbers of lines in input (but I guess it looked like this), but on my machine this one doesn't hang. ?

    Ah, I see, it hangs if I input from STDIN, instead of a file. Have to ^D twice, anyway. Still, since the OP asked for file manipulation, I'd say this was OK for a solution..:wq