in reply to Static function variables without top declaration?
I'm working on something now moving gobs of file scoped lexicals into an AppConfig instance. You could put all of your global state into a singleton AppConfig instance and use that instead of multiple variables.
package MyConfig; use constant CONFIG_PATH => q(/usr/share/myconf.cfg); my $_cfg = undef; sub fetch { $_cfg ||= AppConfig->new( )->file( CONFIG_PATH ); return $_cfg; } package main; fooble(); sub fooble { my $cfg = MyConfig->fetch; print "fooble is", $cfg->fooble(), "\n"; }
|
|---|