filter_fetch_value#

Install a sub that rewrites every value read from the database before your code sees it.

Synopsis#

$db->filter_fetch_value(sub { $_ = decode('UTF-8', $_) });
$db->filter_fetch_value(undef);    # remove the filter

What you get back#

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

Edge cases#

  • The sub works on $_ and changes it in place. It runs only for a value that was found: a missing key’s undef passes unfiltered.

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

Differences from upstream#

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

See also#

  • filter_store_value - the rewrite on the way in

  • filter_fetch_key - the same for keys