diff Lib/Configuration.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 16ada169ca75
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/Configuration.pm	Tue Jul 14 12:54:37 2009 +0400
@@ -0,0 +1,37 @@
+package Configuration;
+use strict;
+
+my $Configured = 0;
+
+sub import {
+    my ($class,$site) = @_;
+    
+    if ($site and $site ne $Configured) {
+        Configure($site);
+        $Configured = $site;
+    } elsif (not $site and not $Configured) {
+        $Configured = 1;
+        require Configuration::Global;
+    }
+}
+
+our %virtualSite;
+
+sub Configure {
+    my $siteName = shift;
+    require Configuration::Global;
+    
+    while ( my ($pattern,$configSite) = each %virtualSite) {
+        next if not $siteName =~ $pattern;
+        if (ref $configSite eq 'CODE') {
+            $configSite->();
+        } elsif (not ref $configSite and $configSite) {
+            require $configSite;
+        }
+        last;
+    }
+}
+
+
+
+1;