|Syntactic Confectionery Delight|
Modulino trick for cgi scriptsby skazat (Hermit)
|on Sep 21, 2008 at 01:43 UTC||Need Help??|
skazat has asked for the
wisdom of the Perl Monks concerning the following question:
I'm trying to use the awesome Modulino trick for a CGI script of mine. The Modulino trick :
(Thanks to the powers that be that got TPJ stuff online - it's quite a nerdy treat and thanks to brian d foy for writing both those up!)
It seems like a good idea, as CGI scripts have a tendency to grow a little too bigger than they should and start looking somewhat like modules, but there may be reasons you don't want to break them up into them.
The problem is, I can't get it to work, without renaming the script from, "something.cgi" to, "something.pm". Currently, my testing server is setup to run ".pm" file ending files in the cgi-bin as a cgi script, so it doesn't seem like that big of a problem, but is there any way to keep the filename as is (something.cgi), for now?
For example, if I try to call my cgi script named, "something.cgi" as a module, via the command line, I'll get something like this:
Obviously, perl is looking for, "something.pm" in the working directory, and not, "something.cgi"
Won't do what's expected - and it's probably illegal to have a module name with a, "." in it.
Although it would be really really cool to subclass this script in another script, it's not necessarily my goal.
My goal is to get some TAP tests for subroutines living in the CGI script for my own internal testing.
I may just leave the Modulino scaffolding in the script and, just before I run the tests, rename the cgi script from, "something.cgi" to, "something.pm", require() in the script and run tests on the subroutines directly. This seems like a way better plan that attempt to capture the output of... STDOUT? from the script by passing arguments.