| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tie::Handle::Scalar; |
|
2
|
1
|
|
|
1
|
|
617
|
use 5.006; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
5
|
1
|
|
|
1
|
|
10
|
use Carp; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
70
|
|
|
6
|
1
|
|
|
1
|
|
725
|
use FileHandle; |
|
|
1
|
|
|
|
|
11599
|
|
|
|
1
|
|
|
|
|
5
|
|
|
7
|
1
|
|
|
1
|
|
363
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $AUTOLOAD $FILEHANDLE); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
695
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = "0.1"; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub TIEHANDLE { |
|
21
|
0
|
|
|
0
|
|
|
my $class = bless {}, shift; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my ($stringref) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if (! defined($stringref)) { |
|
26
|
0
|
|
|
|
|
|
my $temp_s = ''; |
|
27
|
0
|
|
|
|
|
|
$stringref = \$temp_s; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if (ref($stringref) ne "SCALAR") { |
|
31
|
0
|
|
|
|
|
|
croak "need a reference to a scalar,"; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$class->{position} = 0; |
|
35
|
0
|
|
|
|
|
|
$class->{data} = $stringref; |
|
36
|
0
|
|
|
|
|
|
$class->{end} = 0; |
|
37
|
0
|
|
|
|
|
|
my $tmpfile = $class->{tmpfile} = '.tmp.' . $$; |
|
38
|
0
|
0
|
|
|
|
|
$FILEHANDLE = new FileHandle "$tmpfile", O_RDWR|O_CREAT or croak "$tmpfile: $!"; |
|
39
|
0
|
|
|
|
|
|
$class->{FILENO} = $FILEHANDLE->fileno(); |
|
40
|
0
|
|
|
|
|
|
$class; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub FILENO { |
|
44
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
45
|
0
|
|
|
|
|
|
return $class->{FILENO}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub WRITE { |
|
49
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
50
|
0
|
|
|
|
|
|
my($buf,$len,$offset) = @_; |
|
51
|
0
|
0
|
|
|
|
|
$offset = 0 if (! defined $offset); |
|
52
|
0
|
|
|
|
|
|
my $data = substr($buf, $offset, $len); |
|
53
|
0
|
|
|
|
|
|
my $n = length($data); |
|
54
|
0
|
|
|
|
|
|
$class->print($data); |
|
55
|
0
|
|
|
|
|
|
return $n; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub PRINT { |
|
59
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
60
|
0
|
|
|
|
|
|
${$class->{data}} .= join('', @_); |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$class->{position} = length(${$class->{data}}); |
|
|
0
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
1; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub PRINTF { |
|
66
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
67
|
0
|
|
|
|
|
|
my $fmt = shift; |
|
68
|
0
|
|
|
|
|
|
$class->PRINT(sprintf $fmt, @_); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub READ { |
|
72
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my ($buf,$len,$offset) = @_; |
|
75
|
0
|
0
|
|
|
|
|
$offset = 0 if (! defined $offset); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $data = ${ $class->{data} }; |
|
|
0
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if ($class->{end} >= length($data)) { |
|
80
|
0
|
|
|
|
|
|
return 0; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
0
|
|
|
|
|
|
$buf = substr($data,$offset,$len); |
|
83
|
0
|
|
|
|
|
|
$_[0] = $buf; |
|
84
|
0
|
|
|
|
|
|
$class->{end} += length($buf); |
|
85
|
0
|
|
|
|
|
|
return length($buf); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub READLINE { |
|
89
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
90
|
0
|
0
|
|
|
|
|
if ($class->{end} >= length(${ $class->{data} })) { |
|
|
0
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return undef; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
my $recsep = $/; |
|
94
|
0
|
|
|
|
|
|
my $rod = substr(${ $class->{data} }, $class->{end}, -1); |
|
|
0
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$rod =~ m/^(.*)$recsep{0,1}/; # use 0,1 for line sep to include possible no \n on last line |
|
96
|
0
|
|
|
|
|
|
my $line = $1 . $recsep; |
|
97
|
0
|
|
|
|
|
|
$class->{end} += length($line); |
|
98
|
0
|
|
|
|
|
|
return $line; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub CLOSE { |
|
102
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
103
|
0
|
0
|
|
|
|
|
if (-e $class->{tmpfile}) { |
|
104
|
0
|
|
|
|
|
|
$FILEHANDLE->close(); |
|
105
|
0
|
0
|
|
|
|
|
unlink $class->{tmpfile} or warn $!; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
0
|
|
|
|
|
|
$class = undef; |
|
108
|
0
|
|
|
|
|
|
1; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub DESTROY { |
|
112
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
113
|
0
|
0
|
|
|
|
|
if (-e $class->{tmpfile}) { |
|
114
|
0
|
0
|
|
|
|
|
unlink $class->{tmpfile} or warn $!; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
0
|
|
|
|
|
|
$class = undef; |
|
117
|
0
|
|
|
|
|
|
1;undef $class; |
|
|
0
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
__END__ |