diff Lib/IMPL/Object/Singleton.pm @ 45:1b1fb9d54f55

Starting web-application concept
author Sergey
date Fri, 29 Jan 2010 16:19:31 +0300
parents
children 75148ccd732d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Object/Singleton.pm	Fri Jan 29 16:19:31 2010 +0300
@@ -0,0 +1,14 @@
+package IMPL::Object::Singleton;
+use strict;
+use warnings;
+
+my %instances;
+
+sub instance {
+    my $self = shift;
+    
+    $instances{$self} || ($instances{$self} = $self->new(@_));
+}
+
+
+1;