in reply to Re^2: Using guards for script execution?
in thread Using guards for script execution?

provide a namespace that was not package-level to prevent accidental use of "global" variables

For clarification:

Variables declared with my are not package variables. At file-level, they are file scoped, so will be accessible from the declaration until the end of file. When declared inside a block, they are only accessible until the end of that block.

Package variables are declared with our or use vars and are accessible from inside the package they are declared in.

Also, package variables can be accessed by their fully qualified names from anywhere. So, in that sense, are also "global".

Replies are listed 'Best First'.
Re^4: Using guards for script execution?
by R0b0t1 (Initiate) on Mar 03, 2017 at 14:52 UTC

    Right, I'm referring to the unusual case where one accidentally makes use of a variable without redeclaring it and thus unintentionally modifies it in some enclosing scope.

    It doesn't happen often but is something I remember doing.