Tie::ShadowHash

Blurb

Tie::ShadowHash is a Perl module that lets you stack together multiple hash-like data structures, including tied hashes such as DB_File databases or text files parsed into a hash, and then treat them like a merged hash. Lookups are handled in the order of the added sources. You can store additional values, change values, and delete values from the hash and those actions will be reflected in later operations, but the underlying objects are not changed.

Description

If you have several key/value data sources in the form of Perl hashes, tied hashes (of whatever type, including on-disk databases tied with DB_File, GDBM_File, or similar modules), or text files that you want to turn into hashes, and you want to be able to query all of those sources of data at once for a particular key without having to check each one of them individually, this module may be what you're looking for. If you want to use a hash-like data source, even just one, but make modifications to its data over the course of your program that override its contents while your program runs but which don't have any permanent effect on it, this module may be what you're looking for.

Tie::ShadowHash lets you create a "shadow hash" that looks like a regular Perl hash to your program but, behind the scenes, queries a list of data sources. All the data sources must also behave like Perl hashes, but that's the only constraint. They can be regular Perl hashes or other tied hashes, including tied DB_File or GDBM_File hashes or the like to access on-disk databases. All data sources are treated as read-only; modifications to any data is stored in the shadow hash itself, and subsequent accesses reflect any modifications, but none of the data sources are changed.

Requirements

The only requirement for this module is Perl 5.024 or later.

Download

The distribution:

Tie::ShadowHash 2.01 2022-10-08 tar.gz (PGP signature) tar.xz (PGP signature)

An archive of older releases is also available.

Tie::ShadowHash is packaged in Debian 6.0 (squeeze) and later as libtie-shadowhash-perl. Thanks to Stefan Hornburg (Racke) for the packaging. See the Debian package tracker for more information.

Tie::ShadowHash is available from CPAN as the Tie-ShadowHash distribution.

Tie::ShadowHash is maintained using the Git version control system. To check out the current development tree, see GitHub or clone:

    https://git.eyrie.org/git/perl/shadowhash.git

Pull requests on GitHub are welcome. You can also browse the current development source.

Documentation

User documentation:

Developer documentation:

License

The Tie::ShadowHash package as a whole is covered by the following copyright and license:

Copyright 1999, 2002, 2010, 2022 Russ Allbery <rra@cpan.org>

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. This means that you may choose between the two licenses that Perl is released under: the GNU GPL and the Artistic License. Please see your Perl distribution for the details and copies of the licenses.

Some individual source files are covered by other, compatible licenses. For complete copyright and license information, see the file LICENSE in the Tie::ShadowHash source distribution.

Last spun 2022-10-08 from thread modified 2022-06-27