line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Array::FileWriter; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6882
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1011
|
use FileHandle; |
|
1
|
|
|
|
|
13897
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
520
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
806
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# TIEARRAY() |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub TIEARRAY |
18
|
|
|
|
|
|
|
{ |
19
|
1
|
|
|
1
|
|
100
|
my ($class, $file, $fdelim, $rdelim) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
5
|
$fdelim = "|" unless defined $fdelim; |
22
|
1
|
50
|
|
|
|
3
|
$rdelim = "\n" unless defined $rdelim; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
2
|
my $fh; |
25
|
|
|
|
|
|
|
my $close_it; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
5
|
if (ref $file eq 'FileHandle') { |
28
|
0
|
0
|
|
|
|
0
|
croak "FileHandle is not open for writing!" |
29
|
|
|
|
|
|
|
unless $fh->opened; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$fh = $file; |
32
|
0
|
|
|
|
|
0
|
$close_it = 0; |
33
|
|
|
|
|
|
|
} else { |
34
|
1
|
|
|
|
|
12
|
$fh = FileHandle->new(">$file"); |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
176
|
croak "Unable to open file '$file' for writing: $!" |
37
|
|
|
|
|
|
|
unless defined $fh; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
3
|
$close_it = 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
10
|
return bless { |
43
|
|
|
|
|
|
|
FH => $fh, |
44
|
|
|
|
|
|
|
CLOSE_IT => $close_it, |
45
|
|
|
|
|
|
|
FDELIM => $fdelim, |
46
|
|
|
|
|
|
|
RDELIM => $rdelim |
47
|
|
|
|
|
|
|
}, $class; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# PUSH() |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub PUSH |
56
|
|
|
|
|
|
|
{ |
57
|
2
|
|
|
2
|
|
16
|
my $self = shift; |
58
|
2
|
|
|
|
|
9
|
my $fh = $self->{FH}; |
59
|
2
|
|
|
|
|
4
|
my $fdelim = $self->{FDELIM}; |
60
|
2
|
|
|
|
|
4
|
my $rdelim = $self->{RDELIM}; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
4
|
foreach my $elem (@_) { |
63
|
2
|
50
|
|
|
|
6
|
next unless defined $elem; |
64
|
2
|
50
|
|
|
|
6
|
next unless ref $elem eq 'ARRAY'; |
65
|
2
|
|
|
|
|
27
|
print($fh join($fdelim, @$elem), $rdelim); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
# UNTIE(): |
72
|
|
|
|
|
|
|
# |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub UNTIE |
75
|
|
|
|
|
|
|
{ |
76
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
77
|
0
|
|
|
|
|
0
|
$self->{FH}->close; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# FETCHSIZE() |
83
|
|
|
|
|
|
|
# |
84
|
|
|
|
|
|
|
# Pushing elements calls FETCHSIZE(). |
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub FETCHSIZE |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
0
|
|
0
|
return 0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# UNIMPLEMENTED FUNCTIONS: |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
1
|
|
1
|
sub CLEAR { my $self = shift; croak("No CLEAR in " . ref $self) } |
|
1
|
|
|
|
|
205
|
|
98
|
0
|
|
|
0
|
|
0
|
sub DELETE { my $self = shift; croak("No DELETE in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
99
|
0
|
|
|
0
|
|
0
|
sub EXISTS { my $self = shift; croak("No EXISTS in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
100
|
0
|
|
|
0
|
|
0
|
sub EXTEND { my $self = shift; croak("No EXTEND in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
101
|
0
|
|
|
0
|
|
0
|
sub FETCH { my $self = shift; croak("No FETCH in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
102
|
0
|
|
|
0
|
|
0
|
sub POP { my $self = shift; croak("No POP in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
103
|
0
|
|
|
0
|
|
0
|
sub SPLICE { my $self = shift; croak("No SPLICE in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
0
|
|
0
|
sub SHIFT { my $self = shift; croak("No SHIFT in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
105
|
0
|
|
|
0
|
|
0
|
sub STORE { my $self = shift; croak("No STORE in " . ref $self) } |
|
0
|
|
|
|
|
0
|
|
106
|
1
|
50
|
|
1
|
|
7
|
sub STORESIZE { my $self = shift; croak("No STORESIZE in " . ref $self) unless shift == 0 } |
|
1
|
|
|
|
|
9
|
|
107
|
0
|
|
|
0
|
|
|
sub UNSHIFT { my $self = shift; croak("No UNSHIFT in " . ref $self) } |
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
__END__ |