On Wed, 17 Dec 2003 09:32:41 -0800
"Chris Ochs" <[EMAIL PROTECTED]> wrote:

> I'm just trying to see how Apache::Singleton works.  If my code is not
> understandable, that's how far off I probably am from knowing how it works..
> That was why I asked if someone had a complete sample.

A typical usage of Singleton is make a Configuration object
accessable from all packages, without either making global
variable or passing configuration in all methods.

  package My::Config;
  use base qw(Apache::Singleton);

  sub _new_instance {
      my $class = shift;
      # do initialization for config vars
      bless { ... }, $class; # should return blessed object
  }

  package main;
 
  my $config = My::Config->instance;

That'd be a *complete* sample to work.      


--
Tatsuhiko Miyagawa



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to