X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FHash%2FUtil%2Flib%2FHash%2FUtil.pm;h=a4f143ea8521734a26f59333b66c5239c0cc5797;hb=1e73acc8af3eecb1b36ee831483e1e9a7b3d1662;hp=c62a8bf2b6a39c7bdfa99683475eb3b62a753890;hpb=7d3c2c289ea5236d2681b4bfba871738a7751375;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/Hash/Util/lib/Hash/Util.pm b/ext/Hash/Util/lib/Hash/Util.pm index c62a8bf..a4f143e 100644 --- a/ext/Hash/Util/lib/Hash/Util.pm +++ b/ext/Hash/Util/lib/Hash/Util.pm @@ -10,6 +10,8 @@ use Scalar::Util qw(reftype); require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw( + fieldhash fieldhashes + all_keys lock_keys unlock_keys lock_value unlock_value @@ -26,11 +28,21 @@ our @EXPORT_OK = qw( hash_seed hv_store ); -our $VERSION = 0.06; +our $VERSION = 0.07; require DynaLoader; local @ISA = qw(DynaLoader); bootstrap Hash::Util $VERSION; +sub import { + my $class = shift; + if ( grep /fieldhash/, @_ ) { + require Hash::Util::FieldHash; + Hash::Util::FieldHash->import(':all'); # for re-export + } + unshift @_, $class; + goto &Exporter::import; +} + =head1 NAME @@ -38,6 +50,20 @@ Hash::Util - A selection of general-utility hash subroutines =head1 SYNOPSIS + # Field hashes + + use Hash::Util qw(fieldhash fieldhashes); + + # Create a single field hash + fieldhash my %foo; + + # Create three at once... + fieldhashes \ my(%foo, %bar, %baz); + # ...or any number + fieldhashes @hashrefs; + + # Restricted hashes + use Hash::Util qw( hash_seed all_keys lock_keys unlock_keys @@ -79,6 +105,19 @@ don't really warrant a keyword. By default C does not export anything. +=head2 Field hashes + +Field hashes are designed to maintain an association of a reference +with a value. The association is independent of the bless status of +the key, it is thread safe and garbage-collected. These properties +are desirable in the construction of inside-out classes. + +When used with keys that are plain scalars (not references), field +hashes behave like normal hashes. + +Field hashes are defined in a separate module for which C +is a front end. For a detailed description see L. + =head2 Restricted hashes 5.8.0 introduces the ability to restrict a hash to a certain set of