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

后端 未结 5 2250
长发绾君心
长发绾君心 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:10

    set $|=1 before you start printing. Eg.

    perl -e ' $|=1; foreach (1..10) { print "$_ "; sleep(1); }'
    

提交回复
热议问题