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 appropriate constructor method of the class (meaning TIESCALAR, TIEHANDLE, TIEARRAY, or TIEHASH). Typically these are arguments such as might be passed to the dbm_open(3) function of C. The object returned by the constructor is also returned by the tie function, which would be useful if you want to access other methods in CLASSNAME.

�����勰�∽�違�壔��紊���違����������勐����違�勐��茖����茵���ŝ����壔�í�鴻�◐����割�������障����� VARIABLE ��壔��薛�羈�������������紊���違�勐�������с����� CLASSNAME ��壔��罩c����������勉�ŝ����吾�с�壔�����絎�茖���������壔�í�鴻�勐�������с����� 篁����綣���違����������違�������勉�壔�í�鴻�勰�ï����ŝ�潟�潟�鴻����í�壔�帥�<�純��������羝<�������障�� (��ゃ�障�� TIESCALAR, TIEHANDLE, TIEARRAY, TIEHASH)��� ���絽吾�������������壔��C ��� dbm_open(3) ��ŝ�í�勰�∽�違��羝<��綣���違����ŝ����障����� ��潟�潟�鴻����í�壔�帥�ц�������������ŝ����吾�с�壔����壔�障�� tie ��∽�違�с��菴���������障��; ��������� 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:

DBM �����<�ゃ�˨�勉�������ɱぇ�����ŝ�ŝ����吾�с�壔����с�壔��keys ��� values ��勉�������ʒ�∽�違�壔��紊с����ŝ�ŝ�鴻�����菴�����櫝�醇�с����������障����� �����勉�������ɱ�翫����с�壔��each ��∽�違��篏帥�c�☎弘���菴�������茵���ŝ�c����鴻�� ��������������������障�������� 箴�:

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

A class implementing a hash should have the following methods:


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

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


    TIEARRAY classname, LIST
    FETCH this, key
    STORE this, key, value
    FETCHSIZE this
    STORESIZE this, count
    CLEAR this
    PUSH this, LIST
    POP this
    SHIFT this
    UNSHIFT this, LIST
    SPLICE this, offset, length, LIST
    EXTEND this, count
    DELETE this, key
    EXISTS this, key
    DESTROY this
    UNTIE this

A class implementing a filehandle should have the following methods:


    TIEHANDLE classname, LIST
    READ this, scalar, length, offset
    READLINE this
    GETC this
    WRITE this, scalar, length, offset
    PRINT this, LIST
    PRINTF this, format, LIST
    BINMODE this
    EOF this
    FILENO this
    SEEK this, position, whence
    TELL this
    OPEN this, mode, LIST
    CLOSE this
    DESTROY this
    UNTIE this

A class implementing a scalar should have the following methods:


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

Not all methods indicated above need be implemented. See perltie, Tie::Hash, Tie::Array, Tie::Scalar, and Tie::Handle.

筝�荐���勐����⓾�勉�<�純��������絎�茖�������綽�荀���壔�������障�������� perltie, Tie::Hash, Tie::Array, Tie::Scalar, Tie::Handle ��������с����⓾��������������

Unlike dbmopen, the tie function will not use or require a module for you; you need to do that explicitly yourself. See DB_File or the Config module for interesting tie implementations.

dbmopen ��◒�������� tie ��∽�違�壔�≪�吾�ャ�若�˨�� use ��������� require ��������������障�����; ��ɱ����ф��腓榊����̬�����綽�荀������������障����� tie ��勤����恰訓���絎�茖���˨�ゃ����⓾� DB_File ��� Config ��≪�吾�ャ�若�˨�������с����⓾��������������

For further details see perltie, tied.

��眼�ŝ��荅括完��˨�ゃ����⓾�� perltie ��� tied ��� �����с����⓾��������������