The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

NCGI::Singleton - Singleton object for persistent CGI environments

SYNOPSIS

  # In your package
  package MyPackage;
  use base 'NCGI::Singleton';

  # In scripts, other modules, wherever
  use MyPackage;
  my $obj = MyPackage->instance();

DESCRIPTION

NCGI::Singleton is an implementation of Class::Singleton that works in persistent Perl environments such as mod_perl and SpeedyCGI. It is drop-in-replaceable with Class::Singleton so nothing else is documented here.

The reason Class::Singleton doesn't work (as I would like it to) is because it relies on the existence of a global variable in a package. Since globals are not deleted for each request it is not easy to have singletons that only exist for the length of the request.

SEE ALSO

Class::Singleton

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright (C) 2005 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.