1Tie::Handle(3pm)       Perl Programmers Reference Guide       Tie::Handle(3pm)
2
3
4

NAME

6       Tie::Handle, Tie::StdHandle  - base class definitions for tied handles
7

SYNOPSIS

9           package NewHandle;
10           require Tie::Handle;
11
12           @ISA = qw(Tie::Handle);
13
14           sub READ { ... }            # Provide a needed method
15           sub TIEHANDLE { ... }       # Overrides inherited method
16
17           package main;
18
19           tie *FH, 'NewHandle';
20

DESCRIPTION

22       This module provides some skeletal methods for handle-tying classes.
23       See perltie for a list of the functions required in tying a handle to a
24       package.  The basic Tie::Handle package provides a "new" method, as
25       well as methods "TIEHANDLE", "PRINT", "PRINTF" and "GETC".
26
27       For developers wishing to write their own tied-handle classes, the
28       methods are summarized below. The perltie section not only documents
29       these, but has sample code as well:
30
31       TIEHANDLE classname, LIST
32           The method invoked by the command "tie *glob, classname". Asso‐
33           ciates a new glob instance with the specified class. "LIST" would
34           represent additional arguments (along the lines of AnyDBM_File and
35           compatriots) needed to complete the association.
36
37       WRITE this, scalar, length, offset
38           Write length bytes of data from scalar starting at offset.
39
40       PRINT this, LIST
41           Print the values in LIST
42
43       PRINTF this, format, LIST
44           Print the values in LIST using format
45
46       READ this, scalar, length, offset
47           Read length bytes of data into scalar starting at offset.
48
49       READLINE this
50           Read a single line
51
52       GETC this
53           Get a single character
54
55       CLOSE this
56           Close the handle
57
58       OPEN this, filename
59           (Re-)open the handle
60
61       BINMODE this
62           Specify content is binary
63
64       EOF this
65           Test for end of file.
66
67       TELL this
68           Return position in the file.
69
70       SEEK this, offset, whence
71           Position the file.
72
73           Test for end of file.
74
75       DESTROY this
76           Free the storage associated with the tied handle referenced by
77           this.  This is rarely needed, as Perl manages its memory quite
78           well. But the option exists, should a class wish to perform spe‐
79           cific actions upon the destruction of an instance.
80

MORE INFORMATION

82       The perltie section contains an example of tying handles.
83

COMPATIBILITY

85       This version of Tie::Handle is neither related to nor compatible with
86       the Tie::Handle (3.0) module available on CPAN. It was due to an acci‐
87       dent that two modules with the same name appeared. The namespace clash
88       has been cleared in favor of this module that comes with the perl core
89       in September 2000 and accordingly the version number has been bumped up
90       to 4.0.
91
92
93
94perl v5.8.8                       2001-09-21                  Tie::Handle(3pm)
Impressum