You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/helper/cat-yml

33 lines
735 B

#!/usr/bin/perl -CSD
# Purpose: dump yaml configuration files
################################################################################
use strict;
use warnings;
use YAML::XS;
use Hash::Merge qw(merge);
if (@ARGV < 1) {
die 'Error: you did not specify an input file name\n';
}
my $config = {};
my %loaded = ();
foreach my $file (@ARGV) {
next if exists $loaded{$file};
$loaded{$file} = 1;
my $yaml = YAML::XS::LoadFile($file);
my $hm = Hash::Merge->new('RIGHT_PRECEDENT');
$config = $hm->merge($config, $yaml);
}
# YAML::XS::Dump returns raw UTF-8 strings.
binmode \*STDOUT, ':raw';
print YAML::XS::Dump($config);
## END OF FILE #################################################################