You're using strict, which is a Good Thing, but if you do, you need to either use lexical (my) variables, or state that you want a global (with our , use vars, or by prefixing the package name )
In almost all situations, variables that you create should be lexicals.