- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

19 perldbmfilter: Perl DBM Filters

$db = tie %hash, 'DBM', ...
$old_filter = $db->filter_store_key  ( sub { ... } );
$old_filter = $db->filter_store_value( sub { ... } );
$old_filter = $db->filter_fetch_key  ( sub { ... } );
$old_filter = $db->filter_fetch_value( sub { ... } );

The four filter_* methods shown above are available in all the DBM modules that ship with Perl, namely DB_File, GDBM_File, NDBM_File, ODBM_File and SDBM_File.

Each of the methods work identically, and are used to install (or uninstall) a single DBM Filter. The only difference between them is the place that the filter is installed.

To summarise:

filter_store_key
If a filter has been installed with this method, it will be invoked every time you write a key to a DBM database.
filter_store_value
If a filter has been installed with this method, it will be invoked every time you write a value to a DBM database.
filter_fetch_key
If a filter has been installed with this method, it will be invoked every time you read a key from a DBM database.
filter_fetch_value
If a filter has been installed with this method, it will be invoked every time you read a value from a DBM database.

You can use any combination of the methods from none to all four.

All filter methods return the existing filter, if present, or undef in not.

To delete a filter pass undef to it.

ISBN 9781906966027Perl Language Reference ManualSee the print edition