home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tie::StdHash - base class definitions for tied hashes</TITLE>
- <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tie::StdHash - base class definitions for tied hashes</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#caveats">CAVEATS</A></LI>
- <LI><A HREF="#more information">MORE INFORMATION</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tie::Hash, Tie::StdHash - base class definitions for tied hashes</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- package NewHash;
- require Tie::Hash;
- </PRE>
- <PRE>
-
- @ISA = (Tie::Hash);</PRE>
- <PRE>
-
- sub DELETE { ... } # Provides needed method
- sub CLEAR { ... } # Overrides inherited method</PRE>
- <PRE>
-
- package NewStdHash;
- require Tie::Hash;</PRE>
- <PRE>
-
- @ISA = (Tie::StdHash);</PRE>
- <PRE>
-
- # All methods provided by default, define only those needing overrides
- sub DELETE { ... }</PRE>
- <PRE>
-
- package main;</PRE>
- <PRE>
-
- tie %new_hash, 'NewHash';
- tie %new_std_hash, 'NewStdHash';</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This module provides some skeletal methods for hash-tying classes. See
- <A HREF="../../lib/Pod/perltie.html">the perltie manpage</A> for a list of the functions required in order to tie a hash
- to a package. The basic <STRONG>Tie::Hash</STRONG> package provides a <CODE>new</CODE> method, as well
- as methods <CODE>TIEHASH</CODE>, <CODE>EXISTS</CODE> and <CODE>CLEAR</CODE>. The <STRONG>Tie::StdHash</STRONG> package
- provides most methods required for hashes in <A HREF="../../lib/Pod/perltie.html">the perltie manpage</A>. It inherits from
- <STRONG>Tie::Hash</STRONG>, and causes tied hashes to behave exactly like standard hashes,
- allowing for selective overloading of methods. The <CODE>new</CODE> method is provided
- as grandfathering in the case a class forgets to include a <CODE>TIEHASH</CODE> method.</P>
- <P>For developers wishing to write their own tied hashes, the required methods
- are briefly defined below. See the <A HREF="../../lib/Pod/perltie.html">the perltie manpage</A> section for more detailed
- descriptive, as well as example code:</P>
- <DL>
- <DT><STRONG><A NAME="item_TIEHASH_classname%2C_LIST">TIEHASH classname, LIST</A></STRONG><BR>
- <DD>
- The method invoked by the command <CODE>tie %hash, classname</CODE>. Associates a new
- hash instance with the specified class. <CODE>LIST</CODE> would represent additional
- arguments (along the lines of <A HREF="../../lib/AnyDBM_File.html">the AnyDBM_File manpage</A> and compatriots) needed to
- complete the association.
- <P></P>
- <DT><STRONG><A NAME="item_STORE_this%2C_key%2C_value">STORE this, key, value</A></STRONG><BR>
- <DD>
- Store datum <EM>value</EM> into <EM>key</EM> for the tied hash <EM>this</EM>.
- <P></P>
- <DT><STRONG><A NAME="item_FETCH_this%2C_key">FETCH this, key</A></STRONG><BR>
- <DD>
- Retrieve the datum in <EM>key</EM> for the tied hash <EM>this</EM>.
- <P></P>
- <DT><STRONG><A NAME="item_FIRSTKEY_this">FIRSTKEY this</A></STRONG><BR>
- <DD>
- Return the (key, value) pair for the first key in the hash.
- <P></P>
- <DT><STRONG><A NAME="item_NEXTKEY_this%2C_lastkey">NEXTKEY this, lastkey</A></STRONG><BR>
- <DD>
- Return the next key for the hash.
- <P></P>
- <DT><STRONG><A NAME="item_EXISTS_this%2C_key">EXISTS this, key</A></STRONG><BR>
- <DD>
- Verify that <EM>key</EM> exists with the tied hash <EM>this</EM>.
- <P>The <STRONG>Tie::Hash</STRONG> implementation is a stub that simply croaks.</P>
- <P></P>
- <DT><STRONG><A NAME="item_DELETE_this%2C_key">DELETE this, key</A></STRONG><BR>
- <DD>
- Delete the key <EM>key</EM> from the tied hash <EM>this</EM>.
- <P></P>
- <DT><STRONG><A NAME="item_CLEAR_this">CLEAR this</A></STRONG><BR>
- <DD>
- Clear all values from the tied hash <EM>this</EM>.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="caveats">CAVEATS</A></H1>
- <P>The <A HREF="../../lib/Pod/perltie.html">the perltie manpage</A> documentation includes a method called <CODE>DESTROY</CODE> as
- a necessary method for tied hashes. Neither <STRONG>Tie::Hash</STRONG> nor <STRONG>Tie::StdHash</STRONG>
- define a default for this method. This is a standard for class packages,
- but may be omitted in favor of a simple default.</P>
- <P>
- <HR>
- <H1><A NAME="more information">MORE INFORMATION</A></H1>
- <P>The packages relating to various DBM-related implementations (<EM>DB_File</EM>,
- <EM>NDBM_File</EM>, etc.) show examples of general tied hashes, as does the
- <A HREF="../../lib/Config.html">the Config manpage</A> module. While these do not utilize <STRONG>Tie::Hash</STRONG>, they serve as
- good working examples.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tie::StdHash - base class definitions for tied hashes</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-