Ace128 has asked for the wisdom of the Perl Monks concerning the following question:
And, say "addon1.pl" looks like this:use strict; use warnings; my @addons; require "addon1.pl"; my $reg = \INIT(); push(@addons, $reg); require "addon2.pl"; $reg = \INIT(); push(@addons, $reg);
Now, say I do:sub INIT { my $name = shift; print "Hello, $name!"; }
I want that to print:$addons[0]->INIT("Jesus");
And:package addon1; sub new { my $class = shift; my $self = []; return bless $self, $class; } sub ACE_INIT { shift; my $test = shift; $$test = "bar"; } return "addon1";
Maybe not totally perfect, but this works pretty fine...my $pluginname = do "addon1.pl"; my $plugin = new $pluginname; my $test = "Foo..."; $plugin->ACE_INIT(\$test); print $test . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Doing "extensions"/"addons"
by merlyn (Sage) on Jul 29, 2005 at 02:08 UTC | |
|
Re: Doing "extensions"/"addons"
by BUU (Prior) on Jul 29, 2005 at 02:05 UTC |