![]() |
![]()
| ![]() |
![]()
NAMEScope::Container - scope based container SYNOPSISuse Scope::Container; sub getdb { if ( my $dbh = scope_container('db') ) { return $dbh; } else { my $dbh = DBI->connect(...); scope_container('db', $dbh) return $dbh; } } for (1..3) { my $contaier = start_scope_container(); getdb(); # do connect getdb(); # from container getdb(); # from container # $container scope out and disconnect from db } getdb(); # do connect DESCRIPTIONScope::Container is scope based container for temporary items and Database Connections. EXPORTED FUNCTION
LIMITATIONThere is a limit to the order in which the Scope::Container object is deleted. If race condition found, remove all data. my $sc = start_scope_container(); scope_container('bar', 'foo'); my $sc2 = start_scope_container(); scope_container('bar', 'baz'); undef $sc; scope_container('bar'); #null AUTHORMasahiro Nagano <kazeburo {at} gmail.com> Fuji, Goro (gfx) LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|