Package experts,

In the begining, I had one long index.cgi. Then I read a Simple Module Tutorial and got the following --

## index.cgi use strict; use CGI::Simple; use HTML::Template; use MyPackage; # The following are imported from the .conf file below use vars qw( $WIKI_TITLE $CGIURL $DB $TEMPLATE_PATH $TEMPLATE_URL $DEFAULT_TARGET $DEFAULT_ACTION $DEBUGGING $PAGENAME_PATTERN $EMAIL_PATTERN $CGIPATH ); # A set_message handler allows creation of a nice looking, # custom error page. This is based on the example # provided in CGI::Carp docs BEGIN { require 'home.conf'; sub handleErrors { my ($err) = @_; my $t = HTML::Template->new( filename => "$TEMPLATE_PATH/error.tmpl", ); $err =~ s/$CGIPATH //g; $t->param( CGIURL => $CGIURL, TEMPLATE_URL => $TEMPLATE_URL, WIKI_TITLE => $WIKI_TITLE, PAGENAME => 'Error', ERROR => $err, ); print $t->output; } set_message(\&handleErrors); } yadda yadda # grab the cgi vars my $cgi_action = $cgi->param('action'); yadda yadda ## dispatch table follows # Dispatch logic SWITCH: { ($cgi_action eq 'edit') && do { edit($cgi_target, $cgi_searchterm); last SWITCH; }; ($cgi_action eq 'find') && do { find($cgi_target, $cgi_searchterm); last SWITCH; }; yadda yadda # default action view($cgi_target, $cgi_searchterm); }

Now I want to move code for each "run mode" (to borrow CGI::Application's terminology, into its own separate Package like below --

## index.cgi use strict; use CGI::Simple; use HTML::Template; use MyPackage; ## and then, in MyPackage use MyPackage::View; use MyPackage::Edit; use MyPackage::Find; yadda yadda

Things that trip me up are --

To many of the wise monks here, this SoPW entry might seem beginner stuff. But for me, it is the land of the unknown. I guess I am looking for a "Intermediate|Advanced Module(s) Tutorial."

Update: 465945 seems to hit tangentially on what I am asking above, but not quite.

--

when small people start casting long shadows, it is time to go to bed

In reply to Packaging up my code sensibly by punkish

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.