>>>>> "Matt" == Matt Sergeant <[EMAIL PROTECTED]> writes:

Matt> On 21 Apr 2000, (Randal L. Schwartz) wrote:
Matt> and I'd be
Matt> interested in seeing Stonehenge::Reload, but I don't fancy
Matt> searching the archives of this list (which you posted it to,
Matt> IIRC), and a central repository of all your mod_perl stuff would
Matt> be nice.
>> 
>> If they were documented independently of the context in which they
>> appeared, as in WT columns, I'd be happy to.  As is, they'd be these
>> wonderously marvelful snippets of undocumented, slightly opaque code
>> with no operating guide. :)

Matt> Hey that sounds like most of the stuff on CPAN anyway <g>.

>> 
>> Perhaps at least a pointer in my online WT repository to the columns
>> that include mod_perl goodies?  Would that help?

Matt> It sure would... now where is Stonehenge::Reload? ;-)

Only in the archive of the list.   Hey, I could post links to the
mod_perl mailing list archive there too. :)

Just in case you missed it... (but notice, no instructions!):

    package Stonehenge::Reload;

    use vars qw($VERSION);
    $VERSION = (qw$Revision: 1.1 $ )[-1];

    use Apache::Log;

    my %mtime;

    sub reload_me {
      goto &reload_me if &_reload_caller; # test myself first
      goto &_reload_caller;             # now test for caller
    }

    sub _reload_caller {
      my $file = (caller)[1];

      ## Apache->server->log->notice("$$ is testing $file with $mtime{$file}");

      return 0 if exists $mtime{$file} and $mtime{$file} == -M $file;
      ## Apache->server->log->notice("$$ is recompiling $file");
      delete @INC{grep $INC{$_} eq $file, keys %INC};
      my $old = \&{(caller(1))[3]};
      do $file;
      my $new = \&{(caller(1))[3]};
      ## Apache->server->log->notice("$$ got $old => $new for $file");
      return 0 if $old == $new; # safety
      $mtime{$file} = -M $file;
      return 1;
    }

    sub import {
      my $file = (caller)[1];
      ## Apache->server->log->notice("$$ is importing ",__PACKAGE__," into $file");
      $mtime{$file} = -M $file;
    }

    BEGIN {
      __PACKAGE__->import;              # for self reload watching
    };

    1;



-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to