require
is basically the same as dofile
, except for mechanisms that avoid loading the same file multiple times (and some other useful things like loaders). That means, that they can set global variables (though they should not) as well. So, if you set a global variable in one of the required files, the global can be seen in the entire scope of the require function. That means in other required files as well.
Having said that, it is not best practise to set global variables in required
files. It is better to return a table that has functions and variables exported by the module inside. Then you would call those functions like this:
local some_required_file_01 = require "SOME_REQUIRED_FILE_01"
local some_result_01 = some_required_file_01.some_function_01()