-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriter.pl
97 lines (85 loc) · 1.27 KB
/
writer.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use strict;
use warnings;
use lib 'lib';
use Data::CSV::Writer;
# write sequentially
my $writer = Data::CSV::Writer->new(
check_type => 1,
text_csv => {
sep_char => ",",
quote_char => "'",
binary => 1,
eol => "\n",
}
);
#$writer->def({
# node => [
# a => 'INTEGER',
# b => undef,
# test => [
# b => undef,
# a => 'VARCHAR',
# ],
# test2 => [
# a => undef,
# b => 'VARCHAR',
# ],
# ]
#}#);
$writer->def({
node => [
a => 'INTEGER',
b => undef,
'test:b' => undef,
'test:a' => 'VARCHAE',
'test2:a' => undef,
'test2:b' => 'VARCHAR',
]
});
print $writer->def;
print $writer->row({
a => '0',
test => {
a => "http://l'express.fr/"
},
});
print "\n\n";
# write all
print $writer->all(
# first entry must be the definition
#{node => [
# a => 'INTEGER',
# b => undef,
# test => [
# b => undef,
# a => 'VARCHAR',
# ],
# test2 => [
# a => undef,
# b => 'VARCHAR',
# ],
#]},
{node => [
a => 'INTEGER',
b => undef,
'test:b' => undef,
'test:a' => 'VARCHAE',
'test2:a' => undef,
'test2:b' => 'VARCHAR',
]},
{
a => '0',
test => {
a => 6
},
},
);
# indirect constructor
use Data::CSV;
$writer = Data::CSV->writer(
check_type => 1,
);
# direct write all
#
# use Data::CSV;
# print Data::CSV::write(...);