Thread PlugIns mit realisieren...: ins Verzeichnis packen und lööpt... (25 answers)
Opened by Magic at 2004-07-03 01:11

esskar
 2004-07-06 20:04
#83851 #83851
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
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;


Code: (dl )
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!

View full thread PlugIns mit realisieren...: ins Verzeichnis packen und lööpt...