3.2.171 tietie
This function binds a variable to a package class that will provide
the implementation for the variable. Note that functions such as keys and values may return huge list values when used on large objects like DBM files. You may prefer to use the each function to iterate over such. For example: use NDBM_File; tie %ALIASES, "NDBM_File", "/etc/aliases", 1, 0 or die "Can't open aliases: $!\n"; while (($key,$val) = each %ALIASES) { print $key, ' = ', $val, "\n"; } untie %ALIASES; A class implementing a hash should provide the following methods:
TIEHASH $class,
A class implementing an ordinary array should provide the following methods:
TIEARRAY $classname,
(As of this writing, other methods are still being designed. Check the online documentation for additions.) A class implementing a scalar should provide the following methods:
TIESCALAR $classname,
See "Using Tied Variables" in Chapter 5 for detailed discussion of all these methods. Unlike dbmopen , the tie function will not use or require a module for you - you need to do that explicitly yourself. See the DB_File and Config modules for interesting tie implementations. |
|