in reply to Re^2: Changing Local Variable Out of Context
in thread Changing Local Variable Out of Context

But worst of all are global vars. To me, using those is like depending on a "side effect". As a min, declare them in main , but where needed, PASS THEM in as a ref or by value.

Using a global variable as a variable in a procedural manner to store temporary information can be bad, but globals have their place, and especially in perl with the 'local' keyword that allows them to act like environment variables during the scope of a function.

Also, I'm a fan of end-user freedom, so in all my modules I declare my package variables using 'our' instead of 'my', because it's not for me to judge whether some user of my module should override that or not. That would save the OP from jumping through the hoops of PadWalker just to customize some bit of behavior. (whether a better approach is possible for them is a different argument)

  • Comment on Re^3: Changing Local Variable Out of Context