[Kc] dynamically loading and unloading perl packages

Teal ironicface at earthlink.net
Fri Sep 12 14:10:41 CDT 2003


John Reinke wrote:

>I've got a challenge that I just haven't been able to find a solution
>for. I'll describe the feature I need to add to the application, in case
>I'm headed in the wrong direction.
>
>I have a script which runs constantly, watching another application. It
>has certain tasks it performs, and occasionally needs to add and/or
>subtract from the list of tasks it performs through checking to see if a
>config file has changed.
>
>Here's the tricky part: the tasks are performed by custom perl packages
>that are not known until the config file is read. This means that the
>main program needs to be able to dynamically load/initialize or unload
>packages according to changes made to the config file since the last
>time it was read.
>
>I've not been able to figure out how to dynamically load or unload
>packages within a global scope. The closest I've been able to find is
>DynaLoader, which allows dynamically loading C libs into a perl program.
>
>This seems like something that should be easy in perl, but I've not been
>able to figure it out.
>
>Any suggestions?
>
>Thanks,
>John
>
>  
>
My idea,
can't say as I know its a good idea, but ...

is to load the special modules in mini-scripts and then exec () them 
from the controlling script.
I am guessing (though not sure) that since the exec should execute in  a 
seperate (child) shell, when it
returned that shell should close its process, and release the eonvironment.

Teal





More information about the kc mailing list