filter_fetch_key#

Install a sub that rewrites every key read from the database - by keys, each or seq - before your code sees it.

Synopsis#

$db->filter_fetch_key(sub { s/\0$// });   # drop a C string's NUL
$db->filter_fetch_key(undef);            # remove the filter

What you get back#

The filter it replaces, or undef if there was none.

Edge cases#

  • The sub works on $_, a copy of the key, and changes it in place; its return value is ignored.

  • A filter that uses the same database croaks recursion detected in filter_fetch_key.

  • The DBM_Filter module offers ready-made filters (utf8, null, int32 and others) installed through these four methods.

Differences from upstream#

Fully compatible with upstream. Covered by t/81-xs-native/DB_File/110-upstream-db-hash.t.

See also#

  • filter_store_key - the other direction, for keys written

  • filter_fetch_value - the same for values