in reply to Is this a good approach for reducing number of global variables?

For something this small, I wouldn't worry. Besides that, you're only using lexical variables anyway.

The reason to avoid globals is to prevent action at a distance. You have two control branches and a handful of error checks. There's no reason to have subroutines, either. Let glue code be glue code.

I'm a big believer in putting off unnecessary complexity. Your code as it is is simpler without these hoops. If you decide to turn it into a module someday, you won't have too much work to do to generalize it. (It looks awfully specific for that, though.)

  • Comment on Re: Is this a good approach for reducing number of global variables?