1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl
use strict;
sub get_class
{
my ($pluginfile) = @_;
$pluginfile =~ m!(.*?)\.pm$!i;
return $1;
}
my $pluginfile = "Plugin.pm";
my $pluginclass = get_class($pluginfile);
require $pluginfile;
my $obj = undef;
eval ($obj = new $pluginclass);
print $obj->get_name() if $obj;
1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package Plugin;
use strict;
sub new
{
my ($parent, %args) = @_;
my $class = ref($parent) || $parent;
my $self = {};
bless $self, $class;
return $self;
}
sub get_name
{
my ($self) = @_;
return "Plugin!";
}
1;
natürlich muss noch errorchecking und inputvalidation rein!