|laziness, impatience, and hubris|
Of strict, globals, packages and styleby jimbus (Friar)
|on Oct 20, 2005 at 18:17 UTC||Need Help??|
jimbus has asked for the
wisdom of the Perl Monks concerning the following question:
Over the last serveral data processing scripts, I've been refining my style and noticed several patterns. Now, I'm in the process of building a template script which should speed up the writing of future scripts. I'll update the older scripts, too, so things are consistent and easily maintained. And to that end I have a question or two.
Yesterday on the CB, we were discussing strict and that globals were verbotten except for those declared in packages... is that to say that it is exceptable create a package for the purpose housing global variables? I was standing in the shower thinking that declaring all of my general use variables at the top would make the scripts look like my old pascal programs and it occurred to me that maybe I could put some of the things I use in every script (ftp handle, dbi handle, machine name, remote path, local path, etc) in a package and neaten things up a bit.
All of my scripts pretty much do the same thing:
Does it make sense to build a genric script and force the differences out to functions in packages with overloaded names? For example: the template might call the sub "process_line" which would be a different sub based on which network element's package was loaded (NE::WSB, NE::SMSC, etc).
I haven't really thought this entirely through... but I've been thinking and that can be a dangerous thing :)
Never moon a werewolf!