Peter Scott wrote:
On Tue, 04 Oct 2005 05:45:13 -0400, Tom Allison wrote:

It seems that there really isn't any clear way to test a subroutine within a script and not a module. Besides loading it into a module and running everything from there -- any suggestions? I don't see it practical putting a function into a module when the function will only ever be used in that one script.


Really?  I do it all the time.  Mainly to facilitate testing.  The
alternative would be something way too fancy that read the script and
extracted the subroutines.  Alternatively, you could do something like set
an environment variable in your test wrapper, 'do' the script, and have
the script only execute its main block if the environment variable isn't
set... sounds way too ugly though.  I usually put the module in the same
directory or one nearby that I can locate with FindBin in the main program.


OK
Maybe my problem is more pandemic than that.

I have some 200 scripts that I've written over the years and they kind of all sit in ~/bin with all the modules in ~/lib
I was hoping to avoid 200 scripts and 200 modules.

But it sounds like the only way to avoid that, and support testing at the same time, is to write less scripts in the first place.

?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to