One issue I've always struggled with is how to properly test code that's not in the form of a module - in other words, scripts. I use the usual hacky, temporary methods to test my code as I write it or when I find a bug (pring statements, commenting out things, etc), and occasionally the perl debugger. But it's unclear to me how one could write formal tests against a script.

I've gone through 'fad' periods where I tried to write all code in modules (even though most of it wasn't reusable) and then have the script be a simple wrapper that processes command line args and calls the appropriate functions in the module, but the design never felt right.

<tangent>Incidentally, I've been toying with the idea of trying to make executable modules. The file would have a .pm extension, be safe to load from other scripts, and provide a functional or OO interface to all functionality, but would also be executable, with a command-line interface. This could be done by checking $0 to see if the program name is the module name.</tangent>

-ofer

Reply via email to