1 package Tie::StdHandle;
6 our @ISA = 'Tie::Handle';
11 Tie::StdHandle - base class definitions for tied handles
18 @ISA = qw(Tie::Handle);
20 sub READ { ... } # Provide a needed method
21 sub TIEHANDLE { ... } # Overrides inherited method
30 The B<Tie::StdHandle> package provide most methods for file handles described
31 in L<perltie> (the exceptions are C<UNTIE> and C<DESTROY>). It causes tied
32 file handles to behave exactly like standard file handles and allow for
33 selective overwriting of methods.
40 my $fh = \do { local *HANDLE};
42 $fh->OPEN(@_) if (@_);
46 sub EOF { eof($_[0]) }
47 sub TELL { tell($_[0]) }
48 sub FILENO { fileno($_[0]) }
49 sub SEEK { seek($_[0],$_[1],$_[2]) }
50 sub CLOSE { close($_[0]) }
51 sub BINMODE { &CORE::binmode(shift, @_) }
55 $_[0]->CLOSE if defined($_[0]->FILENO);
56 @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]);
59 sub READ { &CORE::read(shift, \shift, @_) }
60 sub READLINE { my $fh = $_[0]; <$fh> }
61 sub GETC { getc($_[0]) }
66 local $\; # don't print any line terminator
67 print $fh substr($_[1], $_[3], $_[2]);