| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::PYX2XML; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
75243
|
use strict; |
|
|
4
|
|
|
|
|
25
|
|
|
|
4
|
|
|
|
|
114
|
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
109
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
8495
|
use Getopt::Std; |
|
|
4
|
|
|
|
|
211
|
|
|
|
4
|
|
|
|
|
258
|
|
|
7
|
4
|
|
|
4
|
|
1893
|
use PYX::SGML::Tags; |
|
|
4
|
|
|
|
|
238777
|
|
|
|
4
|
|
|
|
|
160
|
|
|
8
|
4
|
|
|
4
|
|
2094
|
use Tags::Output::Indent; |
|
|
4
|
|
|
|
|
37629
|
|
|
|
4
|
|
|
|
|
146
|
|
|
9
|
4
|
|
|
4
|
|
31
|
use Tags::Output::Raw; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
1571
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.04; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constructor. |
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
7
|
|
|
7
|
1
|
10017
|
my ($class, @params) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Create object. |
|
18
|
7
|
|
|
|
|
20
|
my $self = bless {}, $class; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Object. |
|
21
|
7
|
|
|
|
|
30
|
return $self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Run script. |
|
25
|
|
|
|
|
|
|
sub run { |
|
26
|
6
|
|
|
6
|
1
|
11
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Process arguments. |
|
29
|
6
|
|
|
|
|
30
|
$self->{'_opts'} = { |
|
30
|
|
|
|
|
|
|
'e' => 'utf-8', |
|
31
|
|
|
|
|
|
|
'h' => 0, |
|
32
|
|
|
|
|
|
|
'i' => 0, |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
6
|
100
|
66
|
|
|
26
|
if (! getopts('e:hi', $self->{'_opts'}) || $self->{'_opts'}->{'h'} |
|
|
|
|
66
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|| @ARGV < 1) { |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
76
|
print STDERR "Usage: $0 [-e in_enc] [-h] [-i] [--version] ". |
|
38
|
|
|
|
|
|
|
"[filename] [-]\n"; |
|
39
|
1
|
|
|
|
|
13
|
print STDERR "\t-e in_enc\tInput encoding (default value ". |
|
40
|
|
|
|
|
|
|
"is utf-8)\n"; |
|
41
|
1
|
|
|
|
|
12
|
print STDERR "\t-h\t\tPrint help.\n"; |
|
42
|
1
|
|
|
|
|
11
|
print STDERR "\t-i\t\tIndent output.\n"; |
|
43
|
1
|
|
|
|
|
10
|
print STDERR "\t--version\tPrint version.\n"; |
|
44
|
1
|
|
|
|
|
12
|
print STDERR "\t[filename]\tProcess on filename\n"; |
|
45
|
1
|
|
|
|
|
10
|
print STDERR "\t[-]\t\tProcess on stdin\n"; |
|
46
|
1
|
|
|
|
|
5
|
return 1; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
5
|
|
|
|
|
211
|
$self->{'_filename_or_stdin'} = $ARGV[0]; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Tags object. |
|
51
|
5
|
|
|
|
|
8
|
my $tags; |
|
52
|
5
|
|
|
|
|
22
|
my %params = ( |
|
53
|
|
|
|
|
|
|
'output_handler' => \*STDOUT, |
|
54
|
|
|
|
|
|
|
'xml' => 1, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
5
|
100
|
|
|
|
15
|
if ($self->{'_opts'}->{'i'}) { |
|
57
|
1
|
|
|
|
|
14
|
$tags = Tags::Output::Indent->new(%params); |
|
58
|
|
|
|
|
|
|
} else { |
|
59
|
4
|
|
|
|
|
36
|
$tags = Tags::Output::Raw->new(%params); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# PYX::SGML::Tags object. |
|
63
|
|
|
|
|
|
|
my $writer = PYX::SGML::Tags->new( |
|
64
|
5
|
|
|
|
|
929
|
'input_encoding' => $self->{'_opts'}->{'e'}, |
|
65
|
|
|
|
|
|
|
'tags' => $tags, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Parse from stdin. |
|
69
|
5
|
50
|
|
|
|
976
|
if ($self->{'_filename_or_stdin'} eq '-') { |
|
70
|
0
|
|
|
|
|
0
|
$writer->parse_handler(\*STDIN); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Parse file. |
|
73
|
|
|
|
|
|
|
} else { |
|
74
|
5
|
|
|
|
|
18
|
$writer->parse_file($self->{'_filename_or_stdin'}); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
5
|
|
|
|
|
35687
|
print "\n"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
86
|
return; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |