简体   繁体   English

Perl输出显示在终端的左侧吗?

[英]Perl output shows on the left side of terminal?

Strangely when I execute a code in Perl, the output always appears on the left side of my command line. 奇怪的是,当我在Perl中执行代码时,输​​出始终出现在命令行的左侧。 For example. 例如。

admin@admin-machine:~$ perl my_program
1 2 3 4 5 admin@admin-machine:~$

How do I get it to show output on a line by itself like the following? 我如何像下面这样单独显示一行输出?

admin@admin-machine:~$ perl my_program
1 2 3 4 5
admin@admin-machine:~$

You need to add a newline (\\n) to the end of your print statements. 您需要在打印语句的末尾添加换行符(\\ n)。 Eg 例如

print "1 2 3 4 5 \n";

Everything is possible assuming you really know what you're doing. 假设您真的知道自己在做什么,那么一切皆有可能。

if(0 == fork()) {
        sleep(1);
        print "1 2 3 4 5";
}

s0me0ne@ws:/tmp$ perl print.pl 
s0me0ne@ws:/tmp$ 1 2 3 4 5

I doubt if it helps someone but... Just answering ;) 我怀疑这是否对某人有帮助,但是...只是回答;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM