“perl”和“perl -w”之间的区别?

时间:2021-02-22 12:13:55

I am learning Perl , very new user . May i know whats the difference between these Perl codes.

我正在学习Perl,非常新用户。我可以知道这些Perl代码有什么不同吗?

#!/usr/bin/perl

&

&

#!/usr/bin/perl -w

1 个解决方案

#1


11  

That is not perl code, it's a shebang, which is used in a linux/unix environment as a way to tell the shell what program should be used to run the program file. It has no effect in windows, but it does activate any switches used.

这不是perl代码,而是一种shebang,它被用于linux/unix环境中,用来告诉shell应该使用什么程序来运行程序文件。它对windows没有影响,但它确实激活了任何使用的开关。

The -w part is a switch for perl, telling it to activate warnings. You can learn more about perl's command line switches by typing perl -h at the command prompt. Read more in perldoc perlrun

-w部分是perl的一个开关,告诉它激活警告。您可以通过在命令提示符中键入perl -h来了解更多关于perl命令行开关的信息。多读perldoc perlrun。

-w is the older version of the use warnings pragma, which is preferred nowadays. While -w is global, use warnings is lexical, and can be activated selectively.

-w是使用警告语的较老版本,现在更受欢迎。虽然-w是全局的,但使用警告是词汇,并且可以有选择地激活。

#1


11  

That is not perl code, it's a shebang, which is used in a linux/unix environment as a way to tell the shell what program should be used to run the program file. It has no effect in windows, but it does activate any switches used.

这不是perl代码,而是一种shebang,它被用于linux/unix环境中,用来告诉shell应该使用什么程序来运行程序文件。它对windows没有影响,但它确实激活了任何使用的开关。

The -w part is a switch for perl, telling it to activate warnings. You can learn more about perl's command line switches by typing perl -h at the command prompt. Read more in perldoc perlrun

-w部分是perl的一个开关,告诉它激活警告。您可以通过在命令提示符中键入perl -h来了解更多关于perl命令行开关的信息。多读perldoc perlrun。

-w is the older version of the use warnings pragma, which is preferred nowadays. While -w is global, use warnings is lexical, and can be activated selectively.

-w是使用警告语的较老版本,现在更受欢迎。虽然-w是全局的,但使用警告是词汇,并且可以有选择地激活。