1 package Tie::StdHandle;
6 use vars qw(@ISA $VERSION);
12 Tie::StdHandle - base class definitions for tied handles
19 @ISA = qw(Tie::Handle);
21 sub READ { ... } # Provide a needed method
22 sub TIEHANDLE { ... } # Overrides inherited method
31 The B<Tie::StdHandle> package provide most methods for file handles described
32 in L<perltie> (the exceptions are C<UNTIE> and C<DESTROY>). It causes tied
33 file handles to behave exactly like standard file handles and allow for
34 selective overwriting of methods.
41 my $fh = \do { local *HANDLE};
43 $fh->OPEN(@_) if (@_);
47 sub EOF { eof($_[0]) }
48 sub TELL { tell($_[0]) }
49 sub FILENO { fileno($_[0]) }
50 sub SEEK { seek($_[0],$_[1],$_[2]) }
51 sub CLOSE { close($_[0]) }
52 sub BINMODE { binmode($_[0]) }
56 $_[0]->CLOSE if defined($_[0]->FILENO);
57 @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]);
60 sub READ { read($_[0],$_[1],$_[2]) }
61 sub READLINE { my $fh = $_[0]; <$fh> }
62 sub GETC { getc($_[0]) }
67 print $fh substr($_[1],0,$_[2])