Add support for getting and deleting global vars at once

This commit is contained in:
Ilia Rostovtsev
2022-02-07 17:07:51 +03:00
parent e00939dc24
commit 3225be4ad1

View File

@@ -11985,6 +11985,9 @@ Examples:
Get variable value previously set on default "main" scope
- globals('get', 'var-1');
Extract variable value previously set on default "main" scope and delete immediately
- globals('got', 'var-1');
Delete variable in default "main" scope
- globals('delete', 'var-1');
@@ -11994,6 +11997,9 @@ Examples:
Get variable value previously set on given "virtual-server" scope
- globals('get', 'var-1', 'virtual-server');
Extract variable value previously set on given "virtual-server" scope and delete immediately
- globals('got', 'var-1', 'virtual-server');
Delete variable in "main" scope
- globals('delete', 'var-1');
@@ -12022,11 +12028,14 @@ if ($action eq 'set') {
$globals->{$scope}->{$variable} = $value
if (defined($variable) && defined($value));
}
elsif ($action eq 'get') {
elsif ($action eq 'get' ||
$action eq 'got') {
if (defined($variable)) {
# Return single global variable in given scope
if (defined($globals->{$scope}) &&
defined($globals->{$scope}->{$variable})) {
globals('delete', $variable, $value, $scope)
if ($action eq 'got');
return $globals->{$scope}->{$variable};
}
else {