line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Writer.pm 456 2009-04-15 12:20:59Z fil $ |
2
|
|
|
|
|
|
|
package Data::Tabular::Dumper::Writer; |
3
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1628
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
########################################################### |
6
|
|
|
|
|
|
|
sub open |
7
|
|
|
|
|
|
|
{ |
8
|
13
|
|
|
13
|
0
|
28
|
my($package, $file )=@_; |
9
|
|
|
|
|
|
|
|
10
|
13
|
50
|
|
|
|
42
|
$file = $file->[0] if 'ARRAY' eq ref $file; |
11
|
|
|
|
|
|
|
|
12
|
13
|
|
|
|
|
19
|
my $fh; |
13
|
13
|
50
|
|
|
|
40
|
if( ref $file ) { |
14
|
0
|
|
|
|
|
0
|
$fh = $file; # assume it's a valid filehandle |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
13
|
|
|
|
|
19
|
$fh=eval { local *FH;}; |
|
13
|
|
|
|
|
67
|
|
18
|
13
|
50
|
|
|
|
1570
|
open $fh, ">$file" or die "Unable to open $file: $!\n"; |
19
|
|
|
|
|
|
|
} |
20
|
13
|
|
|
|
|
112
|
return bless { fh=>$fh, fields=>[] }, $package; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
########################################################### |
25
|
|
|
|
|
|
|
sub close |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
|
my($self)=@_; |
28
|
0
|
|
|
|
|
|
delete $self->{fh}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
########################################################### |
32
|
|
|
|
|
|
|
sub write |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
0
|
0
|
|
my($self, $data)=@_; |
35
|
0
|
|
|
|
|
|
die "You MUST overload ", ref($self), "->write"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
########################################################### |
39
|
|
|
|
|
|
|
sub fields |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
0
|
|
my( $self, $data ) = @_; |
42
|
0
|
|
|
|
|
|
$self->write( $data ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
########################################################### |
46
|
|
|
|
|
|
|
sub page_start |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
0
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
########################################################### |
52
|
|
|
|
|
|
|
sub page_end |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
0
|
0
|
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |