[Petal] Adding support for PAR
William McKee
william at knowmad.com
Fri Feb 25 21:38:12 GMT 2005
I needed to add support to Petal and MKDoc for use within PAR archives.
It was a pretty simple modification to Petal/Hash.pm and
MKDoc/XML/Decode.pm. I've attached a diff for Petal to this email.
Is anyone else working with PAR archives yet? They're great when putting
applications onto other servers where you are not in control of the root
account. They can include XS but I usu. try to get the host to install
the few XS modules I need so as to avoid needing to cross compile.
William
--
Knowmad Services Inc.
http://www.knowmad.com
-------------- next part --------------
--- /home/william/local/Petal/lib/Petal/Hash.pm 2004-06-04 07:57:18.000000000 -0400
+++ Hash.pm 2005-02-25 14:29:32.000000000 -0500
@@ -8,6 +8,25 @@
# import all plugins once
foreach my $include_dir (@INC)
{
+ my @modules;
+ # handle PAR archives
+ if (ref $include_dir eq 'CODE')
+ {
+ next unless keys %PAR::LibCache; # skip if PAR is not loaded
+ while (my ($filename, $zip) = each %PAR::LibCache)
+ {
+ my @mods = $zip->membersMatching( "Petal/Hash/" );
+ foreach my $mod (@mods)
+ {
+ my $fn = $mod->fileName;
+ my ($pm) = $fn =~ /\/(\w+)\.pm$/;
+ warn "$fn = $pm";
+ push @modules, $pm;
+ }
+ }
+ }
+ else
+ {
my $dir = "$include_dir/Petal/Hash";
if (-e $dir and -d $dir)
{
@@ -16,12 +35,14 @@
next;
};
- my @modules = map { s/\.pm$//; $_ }
+ @modules = map { s/\.pm$//; $_ }
grep /\.pm$/,
grep !/^\./,
readdir (DD);
closedir DD;
+ }
+ }
foreach my $module (@modules)
{
@@ -31,7 +52,6 @@
$@ and warn "Cannot import module $module. Reason: $@";
$MODIFIERS->{lc ($module) . ':'} = "Petal::Hash::$module";
}
- }
}
More information about the Petal
mailing list