in reply to Re^4: How to import "global" variables into sub-scripts from main script?
in thread How to import "global" variables into sub-scripts from main script?

the global variables are all correctly shared among the files--so why wouldn't strict be shared, too?

Because strict, warnings, and many other pragmas have a lexical scope. If used at the very top of the file, their scope is limited to that file. do, require, and use create a new lexical scope for the files they execute. Only evaled code inherits the strict and other pragmas from the surrounding lexical scope.

  • Comment on Re^5: How to import "global" variables into sub-scripts from main script?

Replies are listed 'Best First'.
Re^6: How to import "global" variables into sub-scripts from main script?
by LanX (Saint) on Mar 22, 2021 at 16:57 UTC
    > Only evaled code inherits the strict and other pragmas from the surrounding lexical scope.

    and because of the lexical scoping he can also deactivate most pragmas like strict before eval to avoid that problem

    { no strict; eval $CODE; }

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery