Sub::SingletonBuilder - a singleton subroutine builder
use Sub::SingletonBuilder; # simple example *dbh = build_singleton(sub { DBI->connect(...); }); dbh()->execute(...); # declare explicit destructor as well (*dbh, *dbh_disconnect) = build_singleton( sub { DBI->connect(...); }, sub { my $dbh = shift; $dbh->disconnect(); }, );
Kazuho Oku
Copyright (C) 2008 by Cybozu Labs, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Sub::SingletonBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::SingletonBuilder
CPAN shell
perl -MCPAN -e shell install Sub::SingletonBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.