Mailing List Archive

documentation update for tie() in perlfunc
Larry says:
> The tie returns the associated object

my $o = tie %d, 'GDBM_File', "test.gdbm", GDBM_NEWDB, 0600;
$o->sync();

Oh wow! Super!

Here is a documentation update for perlfunc which explains this.

The docs were unclear that the tied package has to be a class (returns
a blessed object), so I changed "package" to "class".

-Andrew


--- /d2/src/perl5.001m/pod/perlfunc.pod Sun Mar 12 00:34:42 1995
+++ perlfunc.pod Wed Sep 13 13:12:55 1995
@@ -2633,14 +2633,17 @@
directory. Has the same caveats about possible directory compaction as
the corresponding system library routine.

-=item tie VARIABLE,PACKAGENAME,LIST
+=item tie VARIABLE,CLASSNAME,LIST

-This function binds a variable to a package that will provide the
-implementation for the variable. VARIABLE is the name of the variable to
-be enchanted. PACKAGENAME is the name of a package implementing objects
-of correct type. Any additional arguments are passed to the "new" method
-of the package (meaning TIESCALAR, TIEARRAY, or TIEHASH). Typically these
-are arguments such as might be passed to the dbm_open() function of C.
+This function binds a variable to a class (see L<perlobj>) that will
+provide the implementation for the variable. VARIABLE is the name of
+the variable to be enchanted. CLASSNAME is the name of a class
+implementing objects of correct type. Any additional arguments are
+passed to the "new" method of the class (meaning TIESCALAR, TIEARRAY,
+or TIEHASH). Typically these are arguments such as might be passed to
+the dbm_open() function of C. The object returned by the "new" method
+is also returned by the tie() function, which would be useful if you
+want to access other methods in CLASSNAME.

Note that functions such as keys() and values() may return huge array
values when used on large objects, like DBM files. You may prefer to
@@ -2653,10 +2656,10 @@
}
untie(%HIST);

-A package implementing an associative array should have the following
+A class implementing an associative array should have the following
methods:

- TIEHASH objectname, LIST
+ TIEHASH classname, LIST
DESTROY this
FETCH this, key
STORE this, key, value
@@ -2665,17 +2668,17 @@
FIRSTKEY this
NEXTKEY this, lastkey

-A package implementing an ordinary array should have the following methods:
+A class implementing an ordinary array should have the following methods:

- TIEARRAY objectname, LIST
+ TIEARRAY classname, LIST
DESTROY this
FETCH this, key
STORE this, key, value
[others TBD]

-A package implementing a scalar should have the following methods:
+A class implementing a scalar should have the following methods:

- TIESCALAR objectname, LIST
+ TIESCALAR classname, LIST
DESTROY this
FETCH this,
STORE this, value