| Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/Tie/StdHandle.pm |
| Statements | Executed 9 statements in 659µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 32µs | 39µs | Tie::StdHandle::BEGIN@3 |
| 1 | 1 | 1 | 17µs | 73µs | Tie::StdHandle::BEGIN@6 |
| 1 | 1 | 1 | 12µs | 12µs | Tie::StdHandle::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | CORE::read |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::BINMODE |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::CLOSE |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::EOF |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::FILENO |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::GETC |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::OPEN |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::READ |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::READLINE |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::SEEK |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::TELL |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::TIEHANDLE |
| 0 | 0 | 0 | 0s | 0s | Tie::StdHandle::WRITE |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Tie::StdHandle; | ||||
| 2 | |||||
| 3 | 2 | 46µs | 2 | 46µs | # spent 39µs (32+7) within Tie::StdHandle::BEGIN@3 which was called:
# once (32µs+7µs) by Tie::Handle::BEGIN@8 at line 3 # spent 39µs making 1 call to Tie::StdHandle::BEGIN@3
# spent 7µs making 1 call to strict::import |
| 4 | |||||
| 5 | 2 | 47µs | 1 | 12µs | # spent 12µs within Tie::StdHandle::BEGIN@5 which was called:
# once (12µs+0s) by Tie::Handle::BEGIN@8 at line 5 # spent 12µs making 1 call to Tie::StdHandle::BEGIN@5 |
| 6 | 2 | 547µs | 2 | 129µs | # spent 73µs (17+56) within Tie::StdHandle::BEGIN@6 which was called:
# once (17µs+56µs) by Tie::Handle::BEGIN@8 at line 6 # spent 73µs making 1 call to Tie::StdHandle::BEGIN@6
# spent 56µs making 1 call to vars::import |
| 7 | 1 | 12µs | @ISA = 'Tie::Handle'; | ||
| 8 | 1 | 1µs | $VERSION = '4.4'; | ||
| 9 | |||||
| 10 | =head1 NAME | ||||
| 11 | |||||
| 12 | Tie::StdHandle - base class definitions for tied handles | ||||
| 13 | |||||
| 14 | =head1 SYNOPSIS | ||||
| 15 | |||||
| 16 | package NewHandle; | ||||
| 17 | require Tie::Handle; | ||||
| 18 | |||||
| 19 | @ISA = qw(Tie::Handle); | ||||
| 20 | |||||
| 21 | sub READ { ... } # Provide a needed method | ||||
| 22 | sub TIEHANDLE { ... } # Overrides inherited method | ||||
| 23 | |||||
| 24 | |||||
| 25 | package main; | ||||
| 26 | |||||
| 27 | tie *FH, 'NewHandle'; | ||||
| 28 | |||||
| 29 | =head1 DESCRIPTION | ||||
| 30 | |||||
| 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. | ||||
| 35 | |||||
| 36 | =cut | ||||
| 37 | |||||
| 38 | sub TIEHANDLE | ||||
| 39 | { | ||||
| 40 | my $class = shift; | ||||
| 41 | my $fh = \do { local *HANDLE}; | ||||
| 42 | bless $fh,$class; | ||||
| 43 | $fh->OPEN(@_) if (@_); | ||||
| 44 | return $fh; | ||||
| 45 | } | ||||
| 46 | |||||
| 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]) } | ||||
| 53 | |||||
| 54 | sub OPEN | ||||
| 55 | { | ||||
| 56 | $_[0]->CLOSE if defined($_[0]->FILENO); | ||||
| 57 | @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]); | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | sub READ { &CORE::read(shift, \shift, @_) } | ||||
| 61 | sub READLINE { my $fh = $_[0]; <$fh> } | ||||
| 62 | sub GETC { getc($_[0]) } | ||||
| 63 | |||||
| 64 | sub WRITE | ||||
| 65 | { | ||||
| 66 | my $fh = $_[0]; | ||||
| 67 | local $\; # don't print any line terminator | ||||
| 68 | print $fh substr($_[1], $_[3], $_[2]); | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | |||||
| 72 | 1 | 6µs | 1; |