line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Capture::TieSTDIN; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Small class for replacing STDIN with a provided string |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
64
|
use 5.006; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
145
|
|
6
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
112
|
|
7
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
146
|
|
8
|
4
|
|
|
4
|
|
26
|
use vars qw{$VERSION}; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
172
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
4
|
|
|
4
|
|
1632
|
$VERSION = '1.14'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub TIEHANDLE { |
14
|
4
|
|
|
4
|
|
8
|
my $class = shift; |
15
|
4
|
|
|
|
|
8
|
my $string = shift; |
16
|
4
|
|
|
|
|
27
|
return bless { |
17
|
|
|
|
|
|
|
string => $string, |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub READ { |
22
|
1
|
|
|
1
|
|
1571
|
my $self = shift; |
23
|
1
|
|
|
|
|
2
|
my $string = shift; |
24
|
1
|
50
|
|
|
|
6
|
unless ( defined $string ) { |
25
|
0
|
|
|
|
|
0
|
$_[0] = undef; |
26
|
0
|
|
|
|
|
0
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
1
|
|
50
|
|
|
8
|
my $offset = $_[2] || 0; |
29
|
1
|
|
|
|
|
4
|
my $length = $_[1]; |
30
|
1
|
|
|
|
|
2
|
my $buffer = substr( $string, $offset, $length ); |
31
|
1
|
|
|
|
|
3
|
my $rv = length $buffer; |
32
|
1
|
|
|
|
|
2
|
$_[0] = $buffer; |
33
|
1
|
|
|
|
|
25
|
return $rv; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub READLINE { |
37
|
4
|
|
|
4
|
|
8654
|
my $self = shift; |
38
|
4
|
|
|
|
|
22
|
my $string = $self->{string}; |
39
|
4
|
50
|
|
|
|
38
|
unless ( defined $$string ) { |
40
|
0
|
|
|
|
|
0
|
return undef; |
41
|
|
|
|
|
|
|
} |
42
|
4
|
50
|
|
|
|
14
|
if ( wantarray ) { |
43
|
0
|
|
|
|
|
0
|
my @lines = split /(?<=\n)/, $$string; |
44
|
0
|
|
|
|
|
0
|
$$string = undef; |
45
|
0
|
|
|
|
|
0
|
return @lines; |
46
|
|
|
|
|
|
|
} else { |
47
|
4
|
100
|
|
|
|
29
|
if ( $$string =~ s/^(.+?\n)// ) { |
48
|
3
|
|
|
|
|
38
|
return "$1"; |
49
|
|
|
|
|
|
|
} else { |
50
|
1
|
|
|
|
|
2
|
my $rv = $$string; |
51
|
1
|
|
|
|
|
2
|
$$string = undef; |
52
|
1
|
|
|
|
|
4
|
return $rv; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub CLOSE { |
58
|
0
|
|
|
0
|
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
return close $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |