有什么办法可以“自动使用"吗?每次我写脚本时使用某些模块? [英] Is there any way to "auto-use" certain modules everytime I write a script?
问题描述
正如标题所示,无论如何,我是否可以自动告诉perl在我编写的每个perl脚本中包含以下内容(除非另有说明)?
As the title indicates, is there anyway that I can automatically tell perl to include the following in every perl script that I write (unless noted otherwise)?
use strict;
use warnings;
use feature 'say';
我知道写三行代码没什么大不了的,但是如果我可以更改一些系统文件或其他东西来制作它,那么它就很好了,这样我就不必再这样做了.
I know it's not a big deal to write three lines, but it would be nice if I could just change some system file or something to make it so I never have to do this again.
谢谢.
推荐答案
如果使用更高版本的perl 5.11.0,则默认情况下启用use strict;
.您何时使用Moose
也会获得免费的strict
免费的warnings
;
If you use perl 5.11.0 of higher, the use strict;
is enabled by default. When do you use Moose
you get free strict
a free warnings
too;
您还可以使用所有必需的功能定义自己的模块,并且所有行都减少为一行,例如:
You can also define your own module with the all needed features, and all lines are reduced to one line, like:
use Myname::defs;
如何开发包含您的需求的模块,请在此处回答:.如果不需要utf8
,则可以将严格答案,警告和功能的简短回答简称为.您还可以查看此问题和
How to develop a module what includes your needs, is answered here: How to make "use My::defaults" with modern perl & utf8 defaults? . If you don't need utf8
you can short the geniue answer to strict, warnins, and features. You also can check this question and this question too.
对于开发,您还可以考虑:
For development you can also consider the:
use strictures 1;
在此处有关的相关信息.
这篇关于有什么办法可以“自动使用"吗?每次我写脚本时使用某些模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!