Mercurial > pub > Impl
comparison Lib/Configuration.pm @ 0:03e58a454b20
Создан репозитарий
author | Sergey |
---|---|
date | Tue, 14 Jul 2009 12:54:37 +0400 |
parents | |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:03e58a454b20 |
---|---|
1 package Configuration; | |
2 use strict; | |
3 | |
4 my $Configured = 0; | |
5 | |
6 sub import { | |
7 my ($class,$site) = @_; | |
8 | |
9 if ($site and $site ne $Configured) { | |
10 Configure($site); | |
11 $Configured = $site; | |
12 } elsif (not $site and not $Configured) { | |
13 $Configured = 1; | |
14 require Configuration::Global; | |
15 } | |
16 } | |
17 | |
18 our %virtualSite; | |
19 | |
20 sub Configure { | |
21 my $siteName = shift; | |
22 require Configuration::Global; | |
23 | |
24 while ( my ($pattern,$configSite) = each %virtualSite) { | |
25 next if not $siteName =~ $pattern; | |
26 if (ref $configSite eq 'CODE') { | |
27 $configSite->(); | |
28 } elsif (not ref $configSite and $configSite) { | |
29 require $configSite; | |
30 } | |
31 last; | |
32 } | |
33 } | |
34 | |
35 | |
36 | |
37 1; |