It'd make your code more "proper" if you passed the variables along with each function. It's just a good coding practice not to use global variables.
If you just want it to work, declare them all global at the beginning of the file, that way you don't have to worry about them...
My $0.02.
---JH