PATCH: Tie::SubstrHash
[p5sagit/p5-mst-13.2.git] / lib / Tie / Hash.pm
index 9a9d059..91ccbee 100644 (file)
@@ -1,5 +1,7 @@
 package Tie::Hash;
 
+our $VERSION = '1.00';
+
 =head1 NAME
 
 Tie::Hash, Tie::StdHash - base class definitions for tied hashes
@@ -8,26 +10,26 @@ 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;
+
+    tie %new_hash, 'NewHash';
+    tie %new_std_hash, 'NewStdHash';
 
 =head1 DESCRIPTION
 
@@ -44,7 +46,7 @@ For developers wishing to write their own tied hashes, the required methods
 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
 
@@ -63,16 +65,18 @@ Retrieve the datum in I<key> for the tied hash I<this>.
 
 =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, value) pair 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>.
@@ -92,14 +96,15 @@ but may be omitted in favor of a simple default.
 
 =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;
@@ -110,9 +115,8 @@ sub new {
 
 sub TIEHASH {
     my $pkg = shift;
-    if (defined &{"{$pkg}::new"}) {
-       carp "WARNING: calling ${pkg}->new since ${pkg}->TIEHASH is missing"
-           if $^W;
+    if (defined &{"${pkg}::new"}) {
+       warnings::warnif("WARNING: calling ${pkg}->new since ${pkg}->TIEHASH is missing");
        $pkg->new(@_);
     }
     else {