in reply to Strict Variables without "my"
Put simply, global variables (without a very good reason) are a 'bad idea'.
Using my outside of a block or sub means that their scope is restricted to the file they are in. This should be wide enough scope for almost any purpose, and will allow you to share the var between subs declared in the same file without needing to pass them as parameters.
However, sharing vars between subs without passing them as parameters is also indicative of bad design (in most cases) as it makes it very difficult for the maintainance programmer coming along later to work out what sub is doing what with each variable.
Discussion on why globals are generally a bad idea is a big subject that would take considerable effort to put over if you are not already aware of the reasons.
|
|---|