Because $DATA is a lexical ("my") variable, it's only accessable to the subroutines defined in its scope. (In this case, a file scope, but you could add a bare block to hide it from other parts of the same file if you really want to.) See also Class::Singleton.package My::Singleton; my $DATA; sub get_data { my $class = shift; $class->_init unless defined $DATA; return bless $DATA, $class; } sub _init { $DATA = { foo => 42 }; }
In reply to Re: poop question
by friedo
in thread poop question
by leocharre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |