author | wenzelm |
Fri, 03 Aug 2012 16:00:12 +0200 | |
changeset 48662 | b171bcd5dd86 |
parent 35022 | c844b93dd147 |
permissions | -rwxr-xr-x |
35022
c844b93dd147
modernized perl scripts: prefer standalone executables;
wenzelm
parents:
29145
diff
changeset
|
1 |
#!/usr/bin/env perl |
26575 | 2 |
# |
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# yxml.pl - simple XML to YXML converter |
|
6 |
# |
|
7 |
||
35022
c844b93dd147
modernized perl scripts: prefer standalone executables;
wenzelm
parents:
29145
diff
changeset
|
8 |
use warnings; |
26575 | 9 |
use strict; |
35022
c844b93dd147
modernized perl scripts: prefer standalone executables;
wenzelm
parents:
29145
diff
changeset
|
10 |
|
26575 | 11 |
use XML::Parser; |
12 |
||
13 |
binmode(STDOUT, ":utf8"); |
|
14 |
||
15 |
sub handle_start { |
|
16 |
print chr(5), chr(6), $_[1]; |
|
17 |
for (my $i = 2; $i <= $#_; $i++) { |
|
18 |
print ($i % 2 == 0 ? chr(6) : "="); |
|
19 |
print $_[$i]; |
|
20 |
} |
|
21 |
print chr(5); |
|
22 |
} |
|
23 |
||
24 |
sub handle_end { |
|
25 |
print chr(5), chr(6), chr(5); |
|
26 |
} |
|
27 |
||
28 |
sub handle_char { |
|
29 |
print $_[1]; |
|
30 |
} |
|
31 |
||
32 |
my $parser = new XML::Parser(Handlers => |
|
33 |
{Start => \&handle_start, |
|
34 |
End => \&handle_end, |
|
35 |
Char => \&handle_char}); |
|
36 |
||
26593 | 37 |
$parser->parse(*STDIN) or die $!; |