stdout和stderr
In Perl, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely?
在Perl中,如何打印一个字符串作为一行STDOUT ? 也就是说,字符串和换行符很好吗?
And similarly, how to print the line to STDERR?
同样,如何将行打印到STDERR?
In Perl, to nicely print a new line to STDOUT, you can use the “say” feature which “Just like print, but implicitly appends a newline”:
在Perl中 ,为了将新行很好地打印到STDOUT,可以使用“说”功能,“就像打印,但隐式地添加换行符”:
use 5.010;
say "hello world!"
An example,
一个例子,
$ perl -de1
main::(-e:1): 1
DB<1> use 5.010;
DB<2> say "hello world"
hello world
DB<3>
In Perl, to print to STDERR, you can print
to STDERR
which is the STDERR:
在Perl中 ,要打印到STDERR,可以print
到STDERR
(即STDERR):
say STDERR "your message here"
For example,
例如,
$ perl -de1
main::(-e:1): 1
DB<1> use 5.010;
DB<2> say STDERR "hello world";
hello world
DB<3>
翻译自: https://www.systutorials.com/how-to-print-a-line-to-stderr-and-stdout-in-perl/
stdout和stderr