我似乎无法创建一个对该类全局且可用于该类的所有子例程的变量。
我看到了所有明显有效的例子,但我无法得到任何我做的工作。
代码:
my $test = new Player(8470598);
package Player;
use strict;
use warnings;
use Const::Fast;
$Player::URL = 'asdfasdasURL';
my $test3 = '33333333';
our $test4 = '44444444444';
const $Player::test0 => 'asdfasdas000';
const my $test1 => 'asdfasdas111';
const our $test2 => 'asdfasdas222';
sub new{
print $Player::URL;
print $Player::test0;
print $test1;
print $test2;
print $test3;
print $test4;
return(bless({}, shift));
}
输出:
Use of uninitialized value $Player::URL in print at D:\Text\Programming\Hockey\test.pl line 19.
Use of uninitialized value $Player::test0 in print at D:\Text\Programming\Hockey\test.pl line 20.
Use of uninitialized value $test1 in print at D:\Text\Programming\Hockey\test.pl line 21.
Use of uninitialized value $Player::test2 in print at D:\Text\Programming\Hockey\test.pl line 22.
Use of uninitialized value $test3 in print at D:\Text\Programming\Hockey\test.pl line 23.
Use of uninitialized value $Player::test4 in print at D:\Text\Programming\Hockey\test.pl line 24.
这里发生了什么?