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;
pgp00000.pgp
Description: PGP signature
