Thread Perl Factory Design Pattern (19 answers)
Opened by rosti at 2014-05-04 12:17

Gast wer
 2014-05-05 23:02
#175280 #175280
ich sehe das problem nicht
Code (perl): (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
25
26
27
28
29
30
31
32
33
34
35
36
37
use strict;
use warnings;
use FindBin q($Bin);
use CGI;
use lib "$Bin/path/to/webside/code";
use sys::Config;
use sys::Core;

my $cgi=CGI->new();
my $conf=sys::Config->new();
my $core=sys::Core->new($cgi,$conf);
my $uri=$core->get_uri();

my @allowed=(
  [qr/sub1\.seite\.de/,'sites::Sub1'],
  [qr/sub2\.seite\.de/,'sites::Sub2'],
  [qr/www\.seite\.de/,'sites::Main'],
  [qr//,'sites::Error'],
);
@allowed=@{$conf->get('websites')};

my $run;
for(@allowed) {
  my ($r,$m)=@$_;
  if($uri=~$r and $m and eval("require $m") ) {
    $run=$m;
    last;
  }
}

die("NO WEBSITE") unless $run;

my $site=$run->new($cgi,$conf);

die($run->error()) unless $site;

print $site->generate();


alle module in "sites::" erben von "sys::Core" und überschreiben das was sie anders brauchen

View full thread Perl Factory Design Pattern