Search code examples
perlcygwincarriage-returnline-endings

cygwin seems to be swallowing my carriage returns


I have a perl script that grabs some files from a remote server and I'd like to be able to represent progress. The way I'm trying to do it is like this:

    print "\tDownloading comp.reg.binary.sdiff.log...\n";
    if(does_file_exist('comp.reg.binary.sdiff.log', @ret)){
        $sftp->get("t-gds/log/comp.reg.binary.sdiff.log", $saveDir, sub {
            my($sftp, $data, $offset, $size) = @_;
            print "\tRead $offset of $size bytes\r";
        });
        print "\n\tDownloaded.\n";
    }else{
        print "\tFile not found on server...skipping.\n";
    }

However, cygwin seems to swallow carriage returns and doesn't print anything until the last print statement. I doubt it because the script is running too fast, because when I change \r to \n, I can see them print out slowly.

Does anyone have any idea why it's not working the way it should?


Solution

  • Did you remember to set $| to 1 first? Sounds like not.