blank.gif (43 bytes)

Church Of The
Swimming Elephant


tie function

Bind a variable to an object class


This function binds a variable to a package class 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 lists when used on large objects, like DBM files. You may prefer to use the each() function to iterate over such. Example:

    # print out history file offsets
    use NDBM_File;
    tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
    while (($key,$val) = each %HIST) {
        print $key, ' = ', unpack('L',$val), "\n";

A class implementing a hash should have the following methods:

    TIEHASH classname, LIST
    DESTROY this
    FETCH this, key
    STORE this, key, value
    DELETE this, key
    EXISTS this, key
    FIRSTKEY this
    NEXTKEY this, lastkey

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

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

A class implementing a scalar should have the following methods:

    TIESCALAR classname, LIST
    DESTROY this
    FETCH this,
    STORE this, value

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 manpage or the Config module for interesting tie() implementations.

For further details see the perltie manpage, tied VARIABLE.


Protect yourself from cyberstalkers, identity thieves, and those who would snoop on you.
Stop spam from invading your inbox without losing the mail you want. We give you more control over your e-mail than any other service.
Block popups, ads, and malicious scripts while you surf the net through our anonymous proxies.
Participate in Usenet, host your web files, easily send anonymous messages, and more, much more.
All private, all encrypted, all secure, all in an easy to use service, and all for only $5.95 a month!

Service Details

Have you gone to church today?
All pages 1999, 2000, 2001, 2002, 2003 Church of the Swimming Elephant unless otherwise stated
Church of the Swimming Elephant1999, 2000, 2001, 2002, 2003 is a wholly owned subsidiary of Packetderm, LLC.

Packetderm, LLC
210 Park Ave #308
Worcester, MA 01609