dakkar has asked for the wisdom of the Perl Monks concerning the following question:
The problem:
What I'm doing:
The loop is something like this:
$SOURCE='stuff.src'; $COMP='stuff.pm'; require $COMP; *dostuff=\&Stuff::dostuff; while (<>) { if (-M $SOURCE < -M $COMP) { # source changed? print "compiling...\n"; system "cp $SOURCE $COMP"; # ok, fake compilation delete $INC{$COMP}; # make sure 'require' will load the module no warnings; # avoid some warnings require $COMP; *dostuff=\&Stuff::dostuff; # import } dostuff($_); }
And the "data" file $SOURCE:
package Stuff; no warnings; sub dostuff { print "ver 1: ",shift,"\n"; } 1;
Is this usable? Does it leak memory (in the real case the compiled file would be quite larger)? Can I use something similar inside a mod_perl handler? Is ignoring the "redefined" warnings potentially dangerous?
Is there a better way?
Thanks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Repeated 'require's
by chromatic (Archbishop) on Nov 11, 2002 at 17:24 UTC | |
|
Re: Repeated 'require's
by Kanji (Parson) on Nov 11, 2002 at 17:38 UTC |