Re: How to re-"use Module" if the Module has changed?
- From: Uri Guttman <uri@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 14:26:57 -0500
>>>>> "PL" == Paul Lalli <mritty@xxxxxxxxx> writes:
PL> andrew.fabbro@xxxxxxxxx wrote:
>> I have a script which runs as a daemon. Periodically, the user wants
>> to change some of the config variables for it. Right now, those config
>> variables are stored in a perl module, and the daemon does a 'use
>> Module' to import them at run-time.
>>
>> What I'd like to do is have the module reread its config if it gets a
>> HUP signal. But how can I say "go and 'use Module' again"? It appears
>> that if you 'use Module' more than once, subsequent calls are ignored.
PL> Completely untested, based soley upon the docs in
PL> perldoc -f require
PL> $SIG{HUP} = sub {
PL> delete $INC{'Module.pm'};
PL> require Module;
Module-> import();
that import is useless as it is generally meant to modify the symbol
table at compile time and this is late in run time.
and you could just slurp in the module (if you know where it is) and
eval it. also i would isolate the data into its own module as there is
no reason (unless the code will change too) to reload the code each
time. and those variables have to be package globals. this leads to
other issues.
i would not even go in this direction and instead would use a config
(not perl code) file (many on cpan) and just reload that into your data
(preferably a single hash for isolation).
uri
--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.
- References:
- How to re-"use Module" if the Module has changed?
- From: andrew . fabbro
- Re: How to re-"use Module" if the Module has changed?
- From: Paul Lalli
- How to re-"use Module" if the Module has changed?
- Prev by Date: Re: How to re-"use Module" if the Module has changed?
- Next by Date: Re: why doesn't sort properly?
- Previous by thread: Re: How to re-"use Module" if the Module has changed?
- Next by thread: Re: How to re-"use Module" if the Module has changed?
- Index(es):
Relevant Pages
|