I cannot seem to create a variable that is global to that class and usable in all subroutines of that class.
I see examples all over that apparently work, but I cannot get anything I do to work.
Code:
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));
}
Output:
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.
What is going on here?