川o・-・) < Singletonクラスを以下のように実装したわけだが、何か問題あ りますか。CPANのClass::Singletonはなんか面倒くさいです。

foreach (1..3) {
print Foo->getInstance(), "\n";
print Singleton->getInstance(), "\n";
}

package Singleton;
my %instances;
sub getInstance {
my $class = shift;
return $instances{$class} ||= $class->_new();
}
sub _new {
return bless {}, shift;
}

package Foo;
use base q/Singleton/;

-----------
Foo=HASH(0x80efc1c)
Singleton=HASH(0x80efc34)
Foo=HASH(0x80efc1c)
Singleton=HASH(0x80efc34)
Foo=HASH(0x80efc1c)
Singleton=HASH(0x80efc34)