Tie::Handle(3pm)

πŸŽ€ Tie::Handle(3pm) πŸŽ€

okay bestie, welcome to Tie::Handle(3pm) from the Perl Programmers Reference Guide β€” it's giving base class definitions for tied handles, and we're gonna make it make sense. πŸ’…βœ¨

🌸 NAME 🌸

Tie::Handle β€” base class definitions for tied handles. slay, that's the whole name section. 🫢

✨ SYNOPSIS ✨

here's the vibe in code, fr fr:

package NewHandle;
require Tie::Handle;

@ISA = qw(Tie::Handle);

sub READ { ... }            # Provide a needed method
sub TIEHANDLE { ... }       # Overrides inherited method

package main;

tie *FH, 'NewHandle';

πŸ’… DESCRIPTION πŸ’…

This module hands you some skeletal methods for handle-tying classes. See perltie for the list of functions you need when you're tying a handle to a package. The basic Tie::Handle package provides a new method, plus the methods TIEHANDLE, PRINT, PRINTF, and GETC. iconic. πŸ‘‘

If you're a dev who wants to write your own tied-handle classes, the methods are summarized below. The perltie section doesn't only document these β€” it has sample code too, iykyk. 🧚

  • TIEHANDLE classname, LIST β€” the method invoked by the command tie *glob, classname. It associates a new glob instance with the specified class. LIST would represent additional arguments (along the lines of AnyDBM_File and compatriots) needed to complete the association.
  • WRITE this, scalar, length, offset β€” writes length bytes of data from scalar starting at offset.
  • PRINT this, LIST β€” prints the values in LIST.
  • PRINTF this, format, LIST β€” prints the values in LIST using format.
  • READ this, scalar, length, offset β€” reads length bytes of data into scalar starting at offset.
  • READLINE this β€” reads a single line.
  • GETC this β€” gets a single character.
  • CLOSE this β€” closes the handle.
  • OPEN this, filename β€” (re-)opens the handle.
  • BINMODE this β€” specifies content is binary.
  • EOF this β€” tests for end of file.
  • TELL this β€” returns the position in the file.
  • SEEK this, offset, whence β€” positions the file. Test for end of file.
  • DESTROY this β€” frees the storage associated with the tied handle referenced by this. This is rarely needed, as Perl manages its memory quite well. But the option exists, should a class wish to perform specific actions upon the destruction of an instance.

🫢 MORE INFORMATION 🫢

The perltie section contains an example of tying handles. that's where the example lives. 🌈

πŸ’€ COMPATIBILITY πŸ’€

This version of Tie::Handle is neither related to nor compatible with the Tie::Handle (3.0) module available on CPAN. It was due to an accident that two modules with the same name appeared. The namespace clash has been cleared in favor of this module that comes with the perl core in September 2000, and accordingly the version number has been bumped up to 4.0. πŸ’€βœ¨

πŸ’– okay that’s the whole page, bestie β€” source/version: perl v5.42.3, date: 2026-11-03, manual: Tie::Handle(3pm). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from