Mercurial > hg > Game > Cerium
comparison bin/cerium @ 332:5950b6ff7fec draft
change bin/cerium
author | aaa |
---|---|
date | Fri, 12 Jun 2009 17:03:18 +0900 |
parents | 4f2423ed1c86 |
children |
comparison
equal
deleted
inserted
replaced
331:4f2423ed1c86 | 332:5950b6ff7fec |
---|---|
108 return if ( ! -e $task_config ); | 108 return if ( ! -e $task_config ); |
109 | 109 |
110 my $parser = XML::LibXML->new(); | 110 my $parser = XML::LibXML->new(); |
111 my $doc = $parser->parse_file("$cerium_path/lib/tasks.xml"); | 111 my $doc = $parser->parse_file("$cerium_path/lib/tasks.xml"); |
112 my $root = $doc->documentElement(); | 112 my $root = $doc->documentElement(); |
113 my $ccs = {}; | |
113 for my $e ($root->childNodes) { | 114 for my $e ($root->childNodes) { |
114 print $e->nodeName, "\n"; | 115 if ( $e->nodeName eq "cc" ) { |
116 my $cc = {}; | |
117 my @att = $e->attributes; | |
118 print $e->nodeName, "\n"; | |
119 | |
120 for my $a (@att) { | |
121 if ( $a->nodeName eq "name" ) { | |
122 print $a->value, "\n"; | |
123 $cc->{"name"} = $a->value; | |
124 } | |
125 } | |
126 | |
127 for my $child ( $e->childNodes ) { | |
128 &compiler($cc, $child); | |
129 } | |
130 | |
131 $ccs->{$cc->{"name"}} = $cc; | |
132 } | |
133 } | |
134 &printcc($ccs); | |
135 } | |
136 | |
137 sub compiler{ | |
138 my ($cc, $e) = @_; | |
139 | |
140 my $type = $e->nodeName; | |
141 my $c = {}; | |
142 for my $child ( $e->childNodes ) { | |
143 my $node = $child->nodeName; | |
144 if ( $node eq "command" ) { | |
145 $c->{"command"} = $child->textContent; | |
146 } elsif ( $node eq "flag" ) { | |
147 $c->{"flag"} .= $child->textContent . " "; | |
148 } | |
149 } | |
150 | |
151 $cc->{$type} = $c; | |
152 } | |
153 | |
154 sub printcc{ | |
155 my ($ccs) = @_; | |
156 | |
157 for my $cc (keys %$ccs) { | |
158 print "$cc", "\n"; | |
159 for my $s (keys %{$ccs->{$cc}}) { | |
160 #print "$s : $cc->{$s}" , "\n"; | |
161 print " $s "; | |
162 my %h = %{$ccs->{$cc}->{$s}}; | |
163 for my $t (keys %h) { | |
164 print " $t : $h{$t}\n"; | |
165 } | |
166 } | |
115 } | 167 } |
116 } | 168 } |
169 | |
117 | 170 |
118 | 171 |
119 __END__ | 172 __END__ |
120 | 173 |
121 =head1 NAME | 174 =head1 NAME |