tie
tie variable, classname, list
- Binds a variable to a package class, classname, that will provide the implementation for the variable. Any additional arguments (list) are passed to the "new" method of the class (meaning
TIESCALAR
,TIEARRAY
, orTIEHASH
). Typically these are arguments such as might be passed to thedbm_open(3)
function of C, but this is package-dependent. The object returned by the "new" method is also returned by thetie
function, which can be useful if you want to access other methods in classname. (The object can also be accessed through thetied
function.)A class implementing a hash should provide the following methods:
TIEHASH $class, LIST DESTROY $self FETCH $self, $key STORE $self, $key, $value DELETE $self, $key EXISTS $self, $key FIRSTKEY $self NEXTKEY $self, $lastkey
A class implementing an ordinary array should provide the following methods:
TIEARRAY $classname, LIST DESTROY $self FETCH $self, $subscript STORE $self, $subscript, $value
A class implementing a scalar should provide the following methods:
TIESCALAR $classname, LIST DESTROY $self FETCH $self, STORE $self, $value
Unlikedbmopen
, thetie
function will notuse
orrequire
a module for you - you need to do that explicitly yourself.