English 中文(简体)
全球文号要求明确的一揽子名称
原标题:Global symbol requires explicit package name
  • 时间:2010-06-29 14:01:19
  •  标签:
  • perl

全球象征需要明确的一揽子名称? 为什么发生这种情况,以及能够造成这一错误的各种案件是什么?

最佳回答

查阅perldiag:

www.un.org/Depts/DGACM/index_spanish.htm 全球符号“%”要求有明确的包装名称。

(F) You ve说,“使用严格”或“使用严格限变”,这表明所有变量必须具有灵活性(使用“米”或“状态”,事先使用“来源”申报,或明确有资格说,全球变量的组合(使用“:”):”)。

问题回答

以前的声明还不完整,也可能发生这种情况。

use strict;

sub test;

test()

# some comment
my $x;

否则现在就发出以下错误信息:

my "
Global symbol "$x" requires explicit package name

这一错误不是在“米”声明中,而是在缺失的半殖民地(;)上,在test()

具体地说,为了在你的法典中说明它是什么原因,你需要张贴你的法典。

The error is outputted and your script is stopped because you ve got use strict or a derivative of it. The error occurs because your program is calling a variable out of scope.

  1. 您本可在次程序/职能范围内使用本人或当地人,但试图在另一程序范围内使用,或在职能要求之外使用。

     sub foo{
        my $bar=0; 
        our ($soap) = 1;
     }
     foo();
     print $bar        , "
    ";  # does not work w/ strict -- bar is only in the scope of the function, not globally defined
     print $main::bar  , "
    ";  # will run, but won t be populated
     print $soap       , "
    ";  # does not work w/ strict -- the package isn t defined
     print $main::soap , "
    ";  # will run and work as intended because of our
    

使用国家变量而不使用<代码> 用途特征“状态”或,除非关键词是作为 CORE书写:状态。

Taken from

事实上,如果你使用<条码>严格使用;,如果你误用<条码>;在发言结尾处,则以下声明(精通)可上<>。 全球象征也要求明确的包装名称。





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...