Dear Monks,

I'm just re-factoring a project that uses Net::Server::PreFork and one of the ugly things in there is the use of hardcoded paths splattered all over the source. Yuck! I thought it would be a good idea to move them to the .conf file of Net::Server with some key, like so:

...
root_html               /srv/www/htdocs
root_cgi                /srv/www/cgi-bin
...

and then read them out by either $server->{server}->{root_html} or the respective $server->get_property('root_html') method call. Unfortunately, it seems as if Net::Server would not populate the config hash with key/value pairs he doesn't know, so everything I add to its config file is undefined/unknown.

I did some code browsing and it seems like Net::Server sets up some kind of template, which is cross-checked against the parameters given, and all unknown params are simply not touched. Although I do believe this might be a good idea for some purpose, it is quite frustrating for my purpose (centralize configuration).

The documentation wasn't very fruitful mentioning any of these "templates", so maybe some of you know how to do it. Perhaps I just oversaw something and contacting the author might be a blamage... ;-).

Thank you

Update: Got it working (after going round the houses). Basically I did some slightly more intelligent cargo cult programming after looking more closely at the inheritances of Net::Server. E.g. Net::Server::PreForkSimple, defines its own options method to add options for the package. I did exactly the same thing and came up with:
sub options { my $self = shift; my $ref = shift; my $prop = $self->{server}; my @newo = qw(root_html root_cgi); # YOUR NEW OPTIONS HERE! $self->SUPER::options($ref); for (@newo){ $prop->{$_} = undef if(!exists $prop->{$_}); $ref->{$_} = \$prop->{$_}; } }
Ok. Problem solved. I have to ask the author though why it has to be that complicated.

Bye
 PetaMem
    All Perl:   MT, NLP, NLU


In reply to Net::Server config-file extension by PetaMem

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.