This is similar to the lexical scope. However, the lookup traverses backward through all of the function calls you've made to reach the current code. It applies only to global and package global variables.
# While a package global variable may be visible within all scopes, its value may change depending on localization and assignment:
\!h # The program below starts by declaring an our variable, $scope, as well as three functions.
\!h # It ends by assigning to $scope and calling main().
our $scope;
sub $inner {
say $scope;
}
sub main { # prints $scope's current value, outer scope, and localizes the variable
say $scope;
local $scope = 'main() scope';
middle();
}
sub middle {
say $scope;
inner();
}
$scope = 'outer scope';
main();
say $scope;