Randal L. Schwartz

NAME

Template::Plugin::DBM::Deep - Template Toolkit plugin for DBM::Deep

SYNOPSIS

  [% USE db = DBM.Deep(file = "my.db" locking = 1 autoflush = 1);
     db.lock;
     db.flintstones = { "flintstone" = ["fred" "wilma"]
                        "rubble" = ["barney" "betty"] };
     db.castaways = ["gilligan" "skipper" "professor" "and the rest" ];
     db.unlock;
  -%]
  ...
  [% db.flintstones.rubble.0; %] -- barney
  [% db.castaways.3; %] -- and the rest

DESCRIPTION

This module permits the direct use of DBM::Deep, a persistent sharable store for nearly arbitrarily nested hashes and arrays, within Template Toolkit code.

The initial constructor returns the top-level DBM::Deep object. All keyword arguments are passed to the DBM::Deep constructor as a flat list. Any single positional argument is presumed to be the file keyword parameter, permitting simple invocations like:

  USE db = DBM.deep("my.db");

All appropriate method calls described in "OO Interface" in DBM::Deep are available. In addition, hash-like objects can use direct keys to get at values:

  db.foo = "bar";
  db.foo; # gets "bar"

And array-like objects can use direct indicies:

  db.mylist = ["a" "b" "c"];
  db.mylist.2; # gets "c"

Caution: VMethods do not work against the hash-like or array-like objects. However, you can use the export method to get an unattached cloned copy of that portion of the database, and then the normal vmethods work:

  "$key\n" FOR key IN db.export.keys;

Failure to export first will result in attempting to access a hash element called keys, which doesn't exist.

There are probably other limitations. If you find other weirdness, let me know so I can update this document.

METHODS

new

Used by Plugin interface.

dbm_deep_class

Used by Plugin interface.

SEE ALSO

DBM::Deep

AUTHOR

Randal L. Schwartz, <merlyn@stonehenge.com>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Randal L. Schwartz, Stonehenge Consulting Services, 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.6.0 or, at your option, any later version of Perl 5 you may have available.