in reply to Why Globals can be a good thing
in thread where do you put your subs

I agree with you on every point you have made in the node I'm replying to.

Globals can be useful, and special globals are simply unavoidable. Further, if you need another package to be able to read a variable directly, it has to be a global. But whenever you need something that is global to the package, you must of course put their declaration before subs. That doesn't mean the entire body should be above the subs. If you have your subs at the end, every single variable declared in file scope is useable by all of your subs! Which in practice means that if you use the same name for a variable, and forget to my it in your sub, you're using the variable that's also used by your script's main code. In most cases, that is NOT handy.

If you use strict, and use lexicals in your subs, ask yourself WHY you do that. Why do you use strict? Why do you use lexicals in subs? One of the reasons to use strict and use lexcials in subs is to avoid using variables that were meant for another part of the code.

If you put subs at the end, do you put module loading there too? After all, use is handled at compile time, so it doesn't matter (technically) if you put it near the top or at the end, or somewhere in between.

Do you first tie your shoelaces and then figure out how you did it, or do you first learn how tieing the laces is done, and then do it?
Do you read the manual after fully comprehending things, or do you read it in advance?
Do you drink a glass of tea, and put the tea bag in the water afterwards?
Is it not far more logical to define things first, and then use them?

Let's have a look at object orientation. To create the object, you use a constructor method, probably new. After that, you can create other objects, and it's quite possible some methods need objects as their parameters (an HTTP::Request object, for example). You can't use an object until its creation! That's how I think you should look at subs: don't trust the interpreter to look for your sub everywhere, just assume you can use a sub only after having defined it, which is after all the way most things in life work. And it'll also increase maintainability, because only the variables you declare explicitly _before_ the subs are global or semi-global.

44696420796F7520732F2F2F65206F
7220756E7061636B3F202F6D736720
6D6521203A29202D2D204A75657264