Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید

8.52. DB_File


Ties a Perl
hash to one of the Berkeley DB database types and lets you use
functions provided in the DB API:

[$X =] tie %hash,  "DB_File", $filename [, $flags, $mode, $DB_HASH];
[$X =] tie %hash, "DB_File", $filename, $flags, $mode, $DB_BTREE;
[$X =] tie @array, "DB_File", $filename, $flags, $mode, $DB_RECNO;

The types are:


$DB_HASH


Stores key/data pairs in data files. Equivalent to other hashing
packages such as DBM, NDBM, ODBM, GDBM, and SDBM.


$DB_BTREE


Stores key/data pairs in a binary tree.


$DB_RECNO


Uses a record (line) number to access fixed-length and
variable-length flat text files through the same key/value-pair
interface as in $DB_HASH and
$DB_BTREE.



After you''ve tie d a hash to a
database:

$db = tie %hash, "DB_File", "filename";

you can access the Berkeley DB API functions:

$db->put($key, $value, R_NOOVERWRITE);  # Invoke the DB "put" function

All the functions defined in the dbopen(3)
manpage are available except close and
dbopen itself. The constants defined in the
dbopen manpage are also available.

The following are the functions available (the comments note only the
differences from the equivalent C function).


$X->del(key[, flags])

Removes key/value pairs from the
database. flags is optional.


$X->fd

Returns
a file descriptor that represents the underlying database. No
difference from the equivalent C function.


$X->get(key, value[, flags])

Retrieves data from the database by key.
flags is optional. The value associated
with key is returned in
value.

put

$X->put(key, value[, flags])

Stores a key/value pair in the
database. flags is optional. If
R_IAFTER or R_IBEFORE is set,
then key is set to the record number of
the inserted key/value pair.


$X->seq(key, value[, flags])

Returns the next sequential key/value
pair from the database. flags is optional.
Both key and
value are set.


$X->sync([flags])

Synchronizes the database by flushing
any cached data to disk. flags is
optional.

/ 875