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
AddressBook(3) User Contributed Perl Documentation AddressBook(3)

AddressBook - Abstract class for using AddressBooks

  use AddressBook;
  $a = AddressBook->new(source => "LDAP:localhost");
  $b = AddressBook->new(source => "DBI:CSV:f_dir=/tmp/data");
  $c = AddressBook->new(source => "PDB");

  $a->search(name => "hersh");
  $entry = $a->read;
  $b->add($entry);

  $entry = AddressBook::Entry->new(attr=>{name => "dleigh"});
  $c->write($entry);

  AddressBook::sync(master=>$a,slave=>$c);

AddressBook provides a unified interface to access various databases for keeping track of contacts. Included with this module are several backends:

  AddressBook::DB::LDAP
  AddressBook::DB::LDIF
  AddressBook::DB::DBI
  AddressBook::DB::PDB
  AddressBook::DB::Text
  AddressBook::DB::HTML

More will be added in the future.

Create a new AddressBook object.

  AddressBook->new(source=$source,\%args)

See the appropriate backend documentation for constructor details.

  AddressBook::sync(master=>$master_db, slave=>$slave_db)
  AddressBook::sync(master=>$master_db, slave=>$slave_db,debug=>1)

Synchronizes the "master" and "slave" databases. The "master" database type must be one that supports random-access methods. The "slave" database type must be one that supports sequential-access methods.

When the 'debug' option is true, debug messages will be printed to stdout. The msg_function paramater, if included, should be a subroutine reference which will be called with a status message is the argument.

1.
For each record in the slave, look for a corresponding record in the master, using the key_fields of each.
If no match is found, the entry is added to the master.
If multiple matches are found, an error occurrs.
If one match is found, then:
If the records match, nothing is done.
If the records do not match, then:
If the slave record's timestamp is newer, the master's entry is merged (see below) with the slave entry's data.
If the master record's timestamp is newer, nothing is done.
2.
The slave database is truncated.
3.
Each record of the master is added to the slave

The 'merging' of the master and slave entries involves taking each attribute in the slave's entry and replacing the corresponding attribute in the master's entry. Note that attributes that are deleted only on the slave are therefore effectively ignored during synchronization.

Similarly, deletions made on the slave database are effectively ignored during synchronization.

  $abook->search(attr=>\%filter);
  while ($entry=$abook->read) {
    print $entry->dump;
  }

\%filter is a list of cannonical attribute/value pairs.

  $entry=$abook->read;

Returns an AddressBook::Entry object

  $abook->update(filter=>\%filter,entry=>$entry)

\%filter is a list of cannonical attriute/value pairs used to identify the entry to be updated.

$entry is an AddressBook::Entry object

  $abook->add($entry)

$entry is an AddressBook::Entry object

  $abook->delete($entry)

$entry is an AddressBook::Entry object

  $abook->truncate

Removes all records from the database.

  @names = $abook->get_attribute_names;

Returns a list of valid backend-specific attribute names

  @names = $abook->get_cannonical_attribute_names;

Returns a list of valid cannonical attribute names

Mark A. Hershberger, <mah@everybody.org> David L. Leigh, <dleigh@sameasiteverwas.net>

  The perl-abook home page at http://perl-abook.sourceforge.net

AddressBook::Config AddressBook::Entry

AddressBook::DB::LDAP AddressBook::DB::LDIF AddressBook::DB::DBI AddressBook::DB::PDB AddressBook::DB::Text AddressBook::DB::HTML

2001-02-02 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.