I have 2 perl modules every module use the second one i.e
Module1.pm
use Module2
Module2.pm
use Module1
what happen on the background when I load those 2 modules with use
use Module1;
use Module2;
could someone explain what happen on the background and why I not enter infinate loop ?
You don’t fall into an infinite loop because of the special hash
%INC:Also, remember that
use Module LISTis equivalent toSo when the main program uses
Module1, the following sequence happens:require Module1(from packagemain)require Module2(from packageModule 1)require Module1(does nothing becauseModule1is already in%INC)Module1->import(into packageModule2)Module2->import(into packageModule1)Module1->import(into packagemain)