首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Global symbol "" requires explicit package name解决思路

2012-02-07 
Global symbol **** requires explicit package name下面是我写的perl script:use strictmy $irm_prop

Global symbol "****" requires explicit package name
下面是我写的perl script:
use strict;

my $irm_prop = ();
$irm_prop{"wo"} = "value";

run后出错:
Global symbol "%irm_prop" requires explicit package name at temp_2.pl line 6.
Execution of temp_2.pl aborted due to compilation errors (#1)
(F) You've said "use strict" or "use strict vars", which indicates
that all variables must either be lexically scoped (using "my" or "state"),
declared beforehand using "our", or explicitly qualified to say
which package the global variable is in (using "::").

这事我用了'use strict'后报的错,但是irm_prop是全局变量,为什么还会报错呢?


[解决办法]
你声明的是$irm_prop,而你使用的是%irm_prop,两者不是同一个变量。

热点排行