reading from stdin via pipe, buffering?

Discussion in 'Perl' started by Rudy Gevaert, Feb 29, 2008.

  1. Rudy Gevaert

    Rudy Gevaert Guest

    Hi,

    I have written an perl program that read from stdin:
    while(<STDIN>)
    {
    chomp
    do_it($_);
    }
    Data is fed to it via a pipe:

    cat myfile | ./myprogram

    When running the program, the program doesn't always read the whole
    line. I'm guessing this has something to do with the stdin buffer.

    I would like to know how I can make that perl gets the whole line. As
    it is clearly failing from time to time.

    Thanks in advance,

    Rudy
     
    Rudy Gevaert, Feb 29, 2008
    #1
    1. Advertisements

  2. Try disabling buffering $|++;
     
    Rodrick Brown, Mar 9, 2008
    #2
    1. Advertisements

  3. Rudy Gevaert

    Joe Smith Guest

    Won't help. $| controls output buffering; it has no affect on STDIN.
     
    Joe Smith, Mar 15, 2008
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.