TT#127355 Switch the application variable into a function

The variable from the main space gets declared too late when we want to
initialize the variable in the module. Instead switch to use a function
that gets called on demand, which will have the available value at that
time. This removes the need to declare $VERSION in a BEGIN section, as
that is error-prone and easy to forget for new code.

Change-Id: I613698169dddd6d7ccf52b16a0ee9994e84b3543
mr10.0
Guillem Jover 5 years ago
parent d25ae07b99
commit 2aeedad442

@ -36,7 +36,7 @@ our @EXPORT_OK = qw(
$system_instance_label
$local_ip
$local_fqdn
$application_version
get_application_version
$application_path
$executable_path
$working_path
@ -145,7 +145,6 @@ our $system_instance_label;
our $local_ip = get_ipaddress();
our $local_fqdn = get_hostfqdn();
our $application_version = ($main::VERSION // $VERSION);
our $application_path = get_applicationpath();
our $executable_path = $FindBin::Bin . '/';
#my $remotefilesystem = "MSWin32";
@ -490,6 +489,13 @@ sub _prepare_working_paths {
}
sub get_application_version {
return $main::VERSION // $VERSION;
}
sub get_applicationpath {
return dirname(abs_path(__FILE__)) . '/';

@ -7,7 +7,7 @@ use NGCP::BulkProcessor::Globals qw(
$system_name
$system_instance_label
$local_fqdn
$application_version
get_application_version
$application_path
$working_path
$executable_path
@ -173,7 +173,7 @@ sub _splashinfo {
my ($configfile) = @_;
configurationinfo($system_name . (length($system_instance_label) ? ' (' . $system_instance_label . ')' : '') . ' [' . $local_fqdn . ']',getlogger(__PACKAGE__));
configurationinfo('application version: ' . $application_version,getlogger(__PACKAGE__));
configurationinfo('application version: ' . get_application_version(),getlogger(__PACKAGE__));
configurationinfo('application path: ' . $application_path,getlogger(__PACKAGE__));
configurationinfo('working path: ' . $working_path,getlogger(__PACKAGE__));
configurationinfo($cpucount . ' cpu(s), multithreading ' . ($enablemultithreading ? 'enabled' : 'disabled'),getlogger(__PACKAGE__));

Loading…
Cancel
Save