package Tie::Hash;
+our $VERSION = '1.00';
+
=head1 NAME
Tie::Hash, Tie::StdHash - base class definitions for tied hashes
package NewHash;
require Tie::Hash;
-
+
@ISA = (Tie::Hash);
-
+
sub DELETE { ... } # Provides needed method
sub CLEAR { ... } # Overrides inherited method
-
-
+
+
package NewStdHash;
require Tie::Hash;
-
+
@ISA = (Tie::StdHash);
-
+
# All methods provided by default, define only those needing overrides
sub DELETE { ... }
-
-
+
+
package main;
-
+
tie %new_hash, 'NewHash';
tie %new_std_hash, 'NewStdHash';
are briefly defined below. See the L<perltie> section for more detailed
descriptive, as well as example code:
-=over
+=over 4
=item TIEHASH classname, LIST
=item FIRSTKEY this
-Return the (key, value) pair for the first key in the hash.
+Return the first key in the hash.
=item NEXTKEY this, lastkey
-Return the next key for the hash.
+Return the next key in the hash.
=item EXISTS this, key
Verify that I<key> exists with the tied hash I<this>.
+The B<Tie::Hash> implementation is a stub that simply croaks.
+
=item DELETE this, key
Delete the key I<key> from the tied hash I<this>.
=head1 MORE INFORMATION
-The packages relating to various DBM-related implemetations (F<DB_File>,
+The packages relating to various DBM-related implementations (F<DB_File>,
F<NDBM_File>, etc.) show examples of general tied hashes, as does the
L<Config> module. While these do not utilize B<Tie::Hash>, they serve as
good working examples.
=cut
use Carp;
+use warnings::register;
sub new {
my $pkg = shift;
sub TIEHASH {
my $pkg = shift;
if (defined &{"${pkg}::new"}) {
- carp "WARNING: calling ${pkg}->new since ${pkg}->TIEHASH is missing"
- if $^W;
+ warnings::warnif("WARNING: calling ${pkg}->new since ${pkg}->TIEHASH is missing");
$pkg->new(@_);
}
else {