You may care to reread Re: Calling a subroutine within a conditional which addresses exactly that issue. If there is stuff in that reply you don't understand, ask.
In general variables should be declared in the smallest scope that makes sense and most often initialised with their first sensible value when they are declared. Think about which parts of the code need to be able to access a variable and declare it so that only those parts can see it (but don't use global variables).
True laziness is hard work