Heya,

I'm trying to use the awesome Modulino trick for a CGI script of mine. The Modulino trick :

* http://www.ddj.com/184416165
* http://www.perlmonks.org/index.pl?node_id=396759

(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:

prompt$ perl -e 'use lib qw(./); use something; something->run()'

It'll fail.

Obviously, perl is looking for, "something.pm" in the working directory, and not, "something.cgi"

Trying,

prompt$ perl -e 'use lib qw(./); use "something.cgi"; something->run() +'

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.


In reply to Modulino trick for cgi scripts by skazat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.