Autrijus,

Looks like it works fine. Below are a couple of diffs for documentation to PAR.pm and PAR::Intro.pod. I didn't add much, just included it where the other functions like read_file() and par_handle() are documented. I've updated Apache::PAR and should be able to implement once the change is implemented in PAR. Oh, and while I was in PAR::Intro I updated the Apache::PAR example. :-) If you have any questions, please let me know.

Thanks,

Nathan

--- PAR.pm.orig    Wed Aug 06 17:08:44 2003
+++ PAR.pm    Tue Aug 12 22:34:36 2003
@@ -78,6 +78,12 @@

use PAR '/home/foo/*.par'; # loads all PAR files in that directory

+Reload modified PAR files from within a program:
+
+    # PAR::reload_libs() reloads modules within PARs
+    PAR::reload_libs('foo.par'); # Reloads modules within foo.par
+    PAR::reload_libs(); # Reloads modules from all loaded PARs
+
=head1 DESCRIPTION

This module lets you easily bundle a typical F<blib/> tree into a zip




--- Intro.pod.orig Wed Aug 06 17:08:44 2003 +++ Intro.pod Tue Aug 12 22:48:22 2003 @@ -243,6 +243,10 @@

Programs can use C<PAR::read_file($filename)> to read file contents inside PAR

+=item *
+
+Programs can use C<PAR::reload_libs()> to reload modules within changed PARs
+
=back


=head2 Derived Modules
@@ -317,13 +321,19 @@
In C<httpd.conf>:

    <VirtualHost *>
-        <IfDefine MODPERL2>
-        PerlModule Apache::ServerUtil
-        </IfDefine>
+        PerlSetVar PARInclude /opt/myapp/myapp.par
+        PerlAddVar PARInclude /opt/anotherapp
        PerlModule Apache::PAR
-        PARDir /opt/myapp
-        PARFile /opt/myapp/myapp.par
    </VirtualHost>
+
+=item *
+
+Alternate configuration inside C<startup.pl>:
+
+        use Apache::PAR qw(
+            /opt/myapp/myapp.par
+            /opt/anotherapp
+        );

=item *





Autrijus Tang wrote:

On Sun, Aug 10, 2003 at 11:40:58PM -0500, Nathan Byrd wrote:


If possible, could you please look at this patch for possible inclusion in PAR? Also, let me know if you want pod for the change as I wasn't sure whether you would want to advertise it as available or not.



I have cleaned it up a bit into the patch below. You can apply it manually or check out the snapshot version to try it out.

PAR::reload_libs() now takes a list of PAR file names to reload
modules from, or default to all PAR files if none are given.

If you're happy with this interface, I'd appreciate a corresponding
POD entry, so I can roll 0.74 immediately.

Thanks,
/Autrijus/

==== //member/autrijus/PAR/lib/PAR.pm#32 - 
/home/autrijus/member/autrijus/PAR/lib/PAR.pm ====
@@ -135,7 +135,8 @@

=cut

-use vars qw(@PAR_INC);                  # explicitly stated PAR library files
+use vars qw(@PAR_INC);  # explicitly stated PAR library files
+use vars qw(%PAR_INC);  # sets {$par}{$file} for require'd modules
use vars qw(@LibCache %LibCache);       # I really miss pseudohash.

my $ver  = $Config::Config{version};
@@ -224,13 +225,28 @@
        else {
            $scheme = $path;
        }
-        my $rv = unpar($path, $file, $member_only, 1);
-        return $rv if defined($rv);
+        my $rv = unpar($path, $file, $member_only, 1) or next;
+        $PAR_INC{$path}{$file} = 1;
+        return $rv;
    }

    return;
}

+sub reload_libs {
+    my @par_files = @_;
+    @par_files = sort keys %LibCache unless @par_files;
+
+    foreach my $par (@par_files) {
+        my $inc_ref = $PAR_INC{$par} or next;
+        delete $LibCache{$par};
+        foreach my $file (sort keys %$inc_ref) {
+            delete $INC{$file};
+            require $file;
+        }
+    }
+}
+
sub read_file {
    my $file = pop;







Reply via email to