Stale %INC cache blocks reloading of edited Perl modules during runtime
26K reputation · 02 Apr 2021, 02:06 UTC
When a Perl module file is edited on disk while the interpreter is still running, subsequent require or use statements continue to execute the previously loaded version because the absolute path remains stored in the %INC hash.
The goal is to understand why the interpreter does not automatically detect the file change and reload the module, and what considerations affect the decision to manually clear %INC entries or employ a reload mechanism. What are the risks of manually deleting $INC{$module} in a long‑running process? Are there safe patterns for using a development‑only reload module such as Module::Reload without introducing inconsistent state? How can one verify that a stale cache is the cause of unexpected behavior without altering the running program?