X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperltie.pod;h=58e9c4375bc731d51e013e6858776005233bec18;hb=151210d1da6387892e1804f7c0c65f5a4da5f893;hp=da4fbe99cf472f3d82daecf0a047a7fbb3e32aa6;hpb=1d2dff63f533f62282a700198c67c41dcb6ad6df;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perltie.pod b/pod/perltie.pod index da4fbe9..58e9c43 100644 --- a/pod/perltie.pod +++ b/pod/perltie.pod @@ -23,7 +23,7 @@ Now you can. The tie() function binds a variable to a class (package) that will provide the implementation for access methods for that variable. Once this magic has been performed, accessing a tied variable automatically triggers -method calls in the proper class. All of the complexity of the class is +method calls in the proper class. The complexity of the class is hidden behind magic methods calls. The method names are in ALL CAPS, which is a convention that Perl uses to indicate that they're called implicitly rather than explicitly--just like the BEGIN() and END() @@ -185,10 +185,12 @@ methods: TIEARRAY, FETCH, STORE, FETCHSIZE, STORESIZE and perhaps DESTROY. FETCHSIZE and STORESIZE are used to provide C<$#array> and equivalent C access. -The methods POP, PUSH, SHIFT, UNSHIFT, SPLICE are required if the perl -operator with the corresponding (but lowercase) name is to operate on the -tied array. The B class can be used as a base class to implement -these in terms of the basic five methods above. +The methods POP, PUSH, SHIFT, UNSHIFT, SPLICE, DELETE, and EXISTS are +required if the perl operator with the corresponding (but lowercase) name +is to operate on the tied array. The B class can be used as a +base class to implement the first five of these in terms of the basic +methods above. The default implementations of DELETE and EXISTS in +B simply C. In addition EXTEND will be called when perl would have pre-extended allocation in a real array. @@ -621,7 +623,9 @@ This is partially implemented now. A class implementing a tied filehandle should define the following methods: TIEHANDLE, at least one of PRINT, PRINTF, WRITE, READLINE, GETC, -READ, and possibly CLOSE and DESTROY. +READ, and possibly CLOSE and DESTROY. The class can also provide: BINMODE, +OPEN, EOF, FILENO, SEEK, TELL - if the corresponding perl operators are +used on the handle. It is especially useful when perl is embedded in some other program, where output to STDOUT and STDERR may have to be redirected in some @@ -680,9 +684,12 @@ This method will be called when the handle is read from via the C or C functions. sub READ { - $r = shift; - my($buf,$len,$offset) = @_; - print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset"; + my $self = shift; + my $$bufref = \$_[0]; + my(undef,$len,$offset) = @_; + print "READ called, \$buf=$bufref, \$len=$len, \$offset=$offset"; + # add to $$bufref, set $len to number of characters read + $len; } =item READLINE this @@ -690,7 +697,7 @@ or C functions. This method will be called when the handle is read from via . The method should return undef when there is no more data. - sub READLINE { $r = shift; "PRINT called $$r times\n"; } + sub READLINE { $r = shift; "READLINE called $$r times\n"; } =item GETC this @@ -829,7 +836,7 @@ destructor (DESTROY) is called, which is normal for objects that have no more valid references; and thus the file is closed. In the second example, however, we have stored another reference to -the tied object in C<$x>. That means that when untie() gets called +the tied object in $x. That means that when untie() gets called there will still be a valid reference to the object in existence, so the destructor is not called at that time, and thus the file is not closed. The reason there is no output is because the file buffers