ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/util/mergejsonhash
Revision: 1.1
Committed: Mon Jan 29 20:41:47 2007 UTC (17 years, 3 months ago) by elmex
Branch: MAIN
CVS Tags: rel-2_2, rel-2_0, rel-2_1, HEAD
Log Message:
some utilities for the face recovery

File Contents

# Content
1 #!/opt/perl/bin/perl
2 # this file just merges all json files (which contain a hash)
3 # are given on the command line arguments together and will
4 # print them out on stdout.
5 #
6 # mergejsonhash /tmp/face.json /tmp/face2.json > /tmp/allface.json
7 use JSON::Syck;
8
9 my %merge;
10 for (@ARGV) {
11 open my $f, $_ or die "$_: $!";
12 my $h = JSON::Syck::Load (do { local $/; <$f> });
13
14
15 for (keys %$h) {
16 warn "key '$_' already present\n" if $merge{$_};
17 $merge{$_} = $h->{$_};
18 }
19 }
20
21 my $first = 1;
22 print "{";
23 for (keys %merge) {
24 print "," unless $first;
25 $first = 0;
26 print "\n\"$_\":\"$merge{$_}\"";
27 }
28 print "\n}\n";