Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在perl脚本中交替声明严格pragmas时会发生什么?_Perl_Perl Module - Fatal编程技术网

在perl脚本中交替声明严格pragmas时会发生什么?

在perl脚本中交替声明严格pragmas时会发生什么?,perl,perl-module,Perl,Perl Module,我是perl新手,正在为我的项目尝试一个示例代码。 当我编写下面给出的代码以在perl中启用严格的pragmas时会发生什么 严格使用 #源代码 没有严格的“变量” #源代码 使用strict#在下一个pragma定义之前是否启用所有strict pragma? ……源代码 没有严格的“潜艇”#从这里开始,仅禁用SUB strict pragma并启用其他功能? 我可以在源代码之间嵌入use Strict Pragma声明吗?use Strict是词汇范围的,这意味着它将保持有效“直到封闭块

我是perl新手,正在为我的项目尝试一个示例代码。 当我编写下面给出的代码以在perl中启用严格的pragmas时会发生什么

严格使用

#源代码

没有严格的“变量”

#源代码

使用strict#在下一个pragma定义之前是否启用所有strict pragma?

……源代码

没有严格的“潜艇”#从这里开始,仅禁用SUB strict pragma并启用其他功能?


我可以在源代码之间嵌入use Strict Pragma声明吗?

use Strict
是词汇范围的,这意味着它将保持有效“直到封闭块、文件或eval(以先到者为准)。”

我认为最好使用范围来隔离Pragma更改:

use strict;

{
    no strict;
    local $foo = 1;
}

local $bar = 1;

这会在设置
条形图时爆炸,但不会在
foo
上爆炸,因为
perldoc strict

如果未提供导入列表,则所有 假设存在可能的限制

您可以随时更改有关(“subs”、“vars”和“refs”)的严格要求