- Timestamp:
- 2015-01-07T14:12:12+13:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/package-kits/linux/files/servlet.pl
r29670 r29671 178 178 sub { 179 179 undef $hash; 180 $hash = {}; 180 181 } 181 182 ], … … 184 185 sub { 185 186 my $file = shift @ARGV; 187 my $new; 186 188 if ($file eq '-') { 187 189 if (isatty *STDIN) { 188 190 print STDERR "Reading XML from STDIN. Press ^D to end\n"; 189 191 } 190 $ hash= read_xml *STDIN;192 $new = read_xml *STDIN; 191 193 } else { 192 194 open FH, '<', $file; 193 $ hash= read_xml *FH;195 $new = read_xml *FH; 194 196 close FH; 197 } 198 # Append the new data to the current data 199 for my $key (keys %$new) { 200 if ($key eq '.attr' and defined $hash->{'.attr'}) { 201 for my $attr ($new->{'.attr'}) { 202 $hash->{'.attr'}->{$attr} = $new->{'.attr'}->{$attr}; 203 } 204 } elsif (defined $hash->{$key}) { 205 if (ref $hash->{$key} ne 'ARRAY') { 206 $hash->{$key} = [ $hash->{$key} ]; 207 } 208 if (ref $new->{$key} eq 'ARRAY') { 209 for my $elem (@{$new->{$key}}) { 210 push @{$hash->{$key}}, $elem; 211 } 212 } else { 213 push @{$hash->{$key}}, $new->{$key}; 214 } 215 } else { 216 $hash->{$key} = $new->{$key}; 217 } 195 218 } 196 219 },
Note:
See TracChangeset
for help on using the changeset viewer.