GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Scope::Container(3) User Contributed Perl Documentation Scope::Container(3)

Scope::Container - scope based container

  use 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

Scope::Container is scope based container for temporary items and Database Connections.

my $scope_container = start_scope_container([-clear => 1]);
Initializing container. The default behavior is inherited all the previous container's data. If set -clear arguments, save previous container's data and create new data.

return values is Scope::Container object. if this object scope exits, current container will be removed, return to the previous state.

my $value = scope_container($key:Str[,$val:Any]);
getter, setter of container data.
in_scope_container
Check if context is initialized

There 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

Masahiro Nagano <kazeburo {at} gmail.com>

Fuji, Goro (gfx)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2010-11-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.