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
|
3
|
|
|
3
|
|
42
|
use 5.006; |
|
3
|
|
|
|
|
9
|
|
6
|
3
|
|
|
3
|
|
12
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
62
|
|
7
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
844
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.15'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub TIEHANDLE { |
12
|
4
|
|
|
4
|
|
8
|
my $class = shift; |
13
|
4
|
|
|
|
|
6
|
my $string = shift; |
14
|
4
|
|
|
|
|
16
|
return bless { |
15
|
|
|
|
|
|
|
string => $string, |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub READ { |
20
|
1
|
|
|
1
|
|
69
|
my $self = shift; |
21
|
1
|
|
|
|
|
1
|
my $string = shift; |
22
|
1
|
50
|
|
|
|
3
|
unless ( defined $string ) { |
23
|
0
|
|
|
|
|
0
|
$_[0] = undef; |
24
|
0
|
|
|
|
|
0
|
return 0; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
50
|
|
|
4
|
my $offset = $_[2] || 0; |
27
|
1
|
|
|
|
|
2
|
my $length = $_[1]; |
28
|
1
|
|
|
|
|
2
|
my $buffer = substr( $string, $offset, $length ); |
29
|
1
|
|
|
|
|
2
|
my $rv = length $buffer; |
30
|
1
|
|
|
|
|
1
|
$_[0] = $buffer; |
31
|
1
|
|
|
|
|
3
|
return $rv; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub READLINE { |
35
|
4
|
|
|
4
|
|
98
|
my $self = shift; |
36
|
4
|
|
|
|
|
12
|
my $string = $self->{string}; |
37
|
4
|
50
|
|
|
|
10
|
unless ( defined $$string ) { |
38
|
0
|
|
|
|
|
0
|
return undef; |
39
|
|
|
|
|
|
|
} |
40
|
4
|
50
|
|
|
|
8
|
if ( wantarray ) { |
41
|
0
|
|
|
|
|
0
|
my @lines = split /(?<=\n)/, $$string; |
42
|
0
|
|
|
|
|
0
|
$$string = undef; |
43
|
0
|
|
|
|
|
0
|
return @lines; |
44
|
|
|
|
|
|
|
} else { |
45
|
4
|
100
|
|
|
|
23
|
if ( $$string =~ s/^(.+?\n)// ) { |
46
|
3
|
|
|
|
|
10
|
return "$1"; |
47
|
|
|
|
|
|
|
} else { |
48
|
1
|
|
|
|
|
2
|
my $rv = $$string; |
49
|
1
|
|
|
|
|
2
|
$$string = undef; |
50
|
1
|
|
|
|
|
3
|
return $rv; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub CLOSE { |
56
|
0
|
|
|
0
|
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
return close $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |