<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Tie::StdHandle; 

use strict;

use Tie::Handle;
our @ISA = 'Tie::Handle';
our $VERSION = '4.6';

=head1 NAME

Tie::StdHandle - base class definitions for tied handles

=head1 SYNOPSIS

    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';

=head1 DESCRIPTION

The B&lt;Tie::StdHandle&gt; package provide most methods for file handles described
in L&lt;perltie&gt; (the exceptions are C&lt;UNTIE&gt; and C&lt;DESTROY&gt;).  It causes tied
file handles to behave exactly like standard file handles and allow for
selective overwriting of methods.

=cut

sub TIEHANDLE 
{
 my $class = shift;
 my $fh    = \do { local *HANDLE};
 bless $fh,$class;
 $fh-&gt;OPEN(@_) if (@_);
 return $fh;
}

sub EOF     { eof($_[0]) }
sub TELL    { tell($_[0]) }
sub FILENO  { fileno($_[0]) }
sub SEEK    { seek($_[0],$_[1],$_[2]) }
sub CLOSE   { close($_[0]) }
sub BINMODE { &amp;CORE::binmode(shift, @_) }

sub OPEN
{
 $_[0]-&gt;CLOSE if defined($_[0]-&gt;FILENO);
 @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]);
}

sub READ     { &amp;CORE::read(shift, \shift, @_) }
sub READLINE { my $fh = $_[0]; &lt;$fh&gt; }
sub GETC     { getc($_[0]) }

sub WRITE
{
 my $fh = $_[0];
 local $\; # don't print any line terminator
 print $fh substr($_[1], $_[3], $_[2]);
}


1;
</pre></body></html>