On 18 Jan 2005 at 15:36, H. Wade Minter wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I'm using PAR/pp to package my Perl/Tk app, and it's all good.  Now I'm 
> moving in the direction of setting up a simple plugin architecture to 
> distribute plugins for my app.  It seems like PAR would be the natural 
> choice to do that, as I'd be able to have the plugins include extra 
> modules in their PAR files to increase functionality, while still allowing 
> the users to run the apps without having Perl installed locally.
> 
> I'm pretty stumped, though, as to the best way to implement this. 
> Currently, I've got code that does something like this:
> 
> foreach my $file ( glob( catfile( $config{plugin_dir}, "*.pl" ) ) )
> {
>      require $file;
> }
> 
> And the .pl files in the plugin_dir provide the functionality.  That's 
> working fine at present.  For the purposes of discussion, let's say we're 
> working with a plugin named scoreboard.pl.
> 
> My first thought was to package scoreboard.pl as scoreboard.par, so I did:
> 
> pp -p -o scoreboard.par scoreboard.pl
> 
> Then, moving scoreboard.par into the plugin_dir, I changed the code to:
> 
> foreach my $file ( glob( catfile( $config{plugin_dir}, "*.par" ) ) )
> {
>      print "Using file $file\n";
>      use PAR $file;
>      require "scoreboard.pl";
> }
> 

How about renaming scoreboard.pl to scoreboard.pm, copy scoreboard.pm to 
site/lib/, 
create a little file include.pl and:

        pp -p -o scoreboard.par include.pl

then:

        use PAR $file;
        require scoreboard;

Normally a .pm file loads a package, but there is no reason why it can't do 
something 
else.

Alan Stewart

Reply via email to