Re: Reloading perl file dynamically



req <reqvidd@xxxxxxxxx> wrote in comp.lang.perl.misc:

So what is the specific loop that gives you trouble? We can't
debug code we don't see. Reduce the problem to a small program
that we can run and post that. Unless you find the problem in
the process, that is.


I see your point of course, but right now I can't break it down for you
in that way (lacking time). For the time being I would be really happy
for suggestsions on how to attack the original general problem - that
is, to load something into memory and from the same script that did
this, call another script that may change dynamically. I don't know the
best way to achieve this.

It's what Module::Reload is supposed to do, and it works fine for me
(see below). Apparently your situation is more involved, but before
we know in which way, fishing for alternatives is just guesswork.

Anno

--- main program ---
#!/usr/bin/perl
use strict; use warnings; $| = 1;

use Module::Reload;

use MyLib; # where run_tests() is defined

while ( 1 ) {
MyLib::run_tests();
sleep 1 until Module::Reload->check;
}
__END__

--- File MyLib.pl ---
package MyLib;
use strict; use warnings;

my $str = "boo";

no warnings 'redefine';
sub run_tests { print "$str\n" }

1;

--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.



Relevant Pages

  • Re: A script to flag commonly misused words
    ... is preferable in general as it allows you to scope warnings. ... use strict; ... I first wrote a script to extract the words to flag from your ... I discovered that at least one of the expressions you ...
    (comp.lang.perl.misc)
  • Re: match machine name to user name
    ... :>: query the server from a client for a username based on a machine name. ... :> It reads better if you post inline or at the bottom. ... Is it better to use the script to poll the server or to ...
    (microsoft.public.scripting.vbscript)
  • Re: match machine name to user name
    ... > dim strComputer, oConn, colComputer, oComputer, oLocator, sUser, sPass ... > set oArgs = wscript.arguments ... I will be running the script from my machine. ... so I guess I am used to reading 'bottom up'. ...
    (microsoft.public.scripting.vbscript)
  • Re: [PATCH] Speed up "make headers_*"
    ... 'use strict' and 'use warnings' is recommended. ... The parentheses are not needed for most of the built-in functions. ... More or less the same comments would apply to the next script as well. ...
    (Linux-Kernel)
  • Re: chopping off the last few lines.
    ... > various pre-processing actions upon it via a ksh script. ... bottom of a file. ... ## The bufarray is a rotating buffer which contains the last N lines ...
    (comp.unix.shell)