Hi monks.

Background

I'm writing an application server, using POE::Component::Server::HTTP (Don't have a client yet) that accepts a request; say /index?foo=bar and calls a routine in a pre-defined package; say MyDocRoot::index.

I'm not trying to duplicate mod_perl's functionality -- this is only a testing-environment/proof-of-concept.

Problem

MyDocRoot.pm is loaded at startup and works fine. My code keeps track of all loaded modules and checks the time the module was loaded against the module's file mtime. When a module changes, the code does:

do $module;

With $module set to the path and filename of the module to reload. The thing does reload since I can see different output from the same request.

The trouble is, old sub-routines and variables are still defined according to what Data::Dumper on \%MyDocRoot:: shows.

I have read perlmod, perlref and various others but I have not yet found a way to reload (or unload) a module completely. I don't know where else to look. Does any monk have some wisdom/pointers to share ?

Update: Just in case, forgot to mention:

This is perl, v5.8.0 built for i386-linux-thread-multi Linux 2.4.21 i686 GNU/Linux (Debian woody)

In reply to Unloading a module completely by holo

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.