Created
April 20, 2016 14:53
-
-
Save gonter/ae84f2a799caf77ad553056f4912edd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use JSON; | |
my @out=(); | |
FILE: foreach my $file (@ARGV) | |
{ | |
my $json; | |
eval { $json= read_json_file($file) }; | |
if ($@) { print STDERR "can not read json data from $file\n"; next FILE; } | |
push (@out, $json); | |
} | |
print encode_json(\@out); | |
exit (0); | |
sub read_json_file | |
{ | |
my $fnm= shift; | |
# BEGIN load JSON data from file content | |
local $/; | |
# print "reading config [$fnm]\n"; | |
open( my $fh, '<:utf8', $fnm ) or return undef; | |
my $json_text = <$fh>; | |
decode_json( $json_text ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment