Conrad, Bill (ThomasTech) <> wrote:
>> Peter Scott replied
>> 
>> Doing a string eval is revolting to begin with, but I would just put
>> in a 
>> 
>>      no warnings 'redefine';
>> 
>> around the subsequent eval.
> 
> Thanks to all who replied to my eval question. I was called away on a
> family matter and am now just getting back to work. 
> 
> I am using the eval within a PERL Tk SGML/XML editor I have developed
> to support plugins associated with the project and/or DTD / schema of
> the file being edited. When the file is opened I load the PERL plugin
> script into a string and eval it. When the file is closed I would
> like to destroy what I have loaded.    
> 
> Is there a better way to do this?

As an alternative to my previous suggestion, why not define your plugins
as Perl classes. In this way each file being edited can have an object
of the appropriate plugin class associated with it, which would make it
easier to edit multiple files at once.

So you might have something like:

sub get_plugin_object {
        my $name = shift;
        my $result = eval "use Plugin::$name; Plugin::$name->new;";
        die $@ if $@;
        return $result;
}

Perhaps you could derive your plugin classes from a common base class
that has an autoload function which could catch calls to undefined
plugin functions and do something sensible.

Of course code is not unloaded, that may not be possible. You don't say
why you want to unload/destroy the plugin code. Is it important?

HTH

-- 
Brian Raven



=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to