The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

AnyDBM_File::Importer - Import DBM package symbols when using AnyDBM_File

SYNOPSIS

BEGIN {
   @AnyDBM_File::ISA = qw( DB_File SDBM_File ) unless @AnyDBM_File::ISA;
}
use AnyDBM_File;
use vars qw( $DB_BTREE &R_DUP); # must declare the globals you expect to use
use AnyDBM_File::Importer qw(:bdb); # an import tag is REQUIRED

my %db;
$DB_BTREE->{'flags'} = R_DUP;
tie( %db, 'AnyDBM_File', O_CREAT | O_RDWR, 0644, $DB_BTREE);

DESCRIPTION

This module allows symbols (like $DB_HASH, R_DUP, etc.) to be imported into the caller's namespace when using the AnyDBM_File DBM auto-selection package. AnyDBM_File includes its auto-selected module by using require, which unlike use does not export symbols in the required packages @EXPORT array.

This is essentially a hack because it relies on AnyDBM_File internal behavior. Specifically, at the time of DBM module selection, AnyDBM_File sets its @ISA to a length 1 array containing the package name of the selected DBM module.

USAGE NOTES

Use of AnyDBM_File::Importer within module code currently requires a kludge. Symbols of imported variables or constants need to be declared globals, as in the SYNOPSIS above. This is not necessary when AnyDBM_File::Importer is used in package main. Better solutions are hereby solicited with advance gratitude.

AnyDBM_File::Importer consists entirely of an import function. To import the symbols, a tag must be given. More than one tag can be supplied. Symbols cannot be individually specified at the moment.

:bdb    DB_File (BDB) symbols ($DB_*, R_*, O_*)
:db     $DB_* type hashrefs
:R      R_* constants (R_DUP, R_FIRST, etc)
:O      O_* constants (O_CREAT, O_RDWR, etc)
:other  Exportable symbols not in any of the above groups
:all    All exportable symbols

Exportable symbols to be completely ignored can be added to @AnyDBM_File::Importer::IGNORED_SYMBOLS. By default, this list includes the following GNU-undefined symbols:

R_NOKEY, R_SNAPSHOT 
O_ALIAS, O_ASYNC, O_DEFER, O_DIRECTORY, O_EXLOCK, O_LARGEFILE
O_RANDOM, O_RAW, O_RSRC, O_SEQUENTIAL, O_SHLOCK, O_TEMPORARY

AUTHOR - Mark A. Jensen

Email: maj -at- fortinbras -dot- us
http://fortinbras.us
http://www.bioperl.org/wiki/Mark_Jensen

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.