How can I print text immediately without waiting for a newline in Perl?

后端 未结 5 2228
长发绾君心
长发绾君心 2021-02-19 07:43

I have a computationally expensive task in perl, and would like to inform the user that computation is ongoing by printing out a period after each portion of the computation is

5条回答
  •  礼貌的吻别
    2021-02-19 08:06

    What worked for me was to put the line

    STDOUT->autoflush(1);
    

    before my line

    print ".";
    

    inside my existing loop. Didn't use the sleep for fear of slowing the things down even more.

提交回复
热议问题