gpt4 book ai didi

linux - perl shebang : `Too late for "-Mstrict"`

转载 作者:行者123 更新时间:2023-12-03 09:46:47 25 4
gpt4 key购买 nike

我有以下可敬的 perl 脚本 x.pl:

#!/usr/bin/env -S perl -Mstrict -wp
s/a/b/;

如果我用 ./x.plperl x.pl 运行它,它会用

Too late for "-Mstrict" option at ./x.pl line 1.

但是……为什么?我认为“为时已晚......”只是 -CSDA-T 之类的问题,因为“流已经打开”。此外,shebang 行实际上不是简单地使用指定的开关调用 perl 吗?

最佳答案

-M-m 开关不适用于 Perl 脚本。

#!/usr/bin/perl -Mstrict
# shebang.pl
print 42;

$ perl -Mdiagnostics shebang.pl

Too late for "-Mstrict" option at - line 1 (#1)(X) The #! line (or local equivalent) in a Perl script contains the-M, -m or -C option.

In the case of -M and -m, this is an error because those optionsare not intended for use inside scripts. Use the use pragma instead.

The -C option only works if it is specified on the command line aswell (with the same sequence of letters or numbers following). Eitherspecify this option on the command line, or, if your system supportsit, make your script executable and run it directly instead of passingit to perl.

Uncaught exception from user code:Too late for "-Mstrict" option at - line 1.

关于linux - perl shebang : `Too late for "-Mstrict"`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64884488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com