YAML::Merge::Simple - Recursively merge two or more YAMLs, simply
version 0.01_01
use YAML::Merge::Simple qw/ merge_files /; # a: 1 my $yaml1 = shift; # a: 100 # b: 2 my $yaml2 = shift; # Merge with righthand hash taking precedence my $new_yaml = merge_files $yaml1,yaml2 # $c (note: a: 100 has overridden a: 1) # a: 100 # b: 2
YAML::Merge::Simple will recursively merge two or more YAML files and return the result as a string with the content of a new YAML.
This is just a wrapper around Hash::Merge::Simple which uses YAML::XS to load the YAMLs into hashes, uses Hash::Merge::Simple to merge them and them uses YAML::XS again to dump the resulting hash back to YAML:
Merge $file1 through $fileN, with the nth-most (rightmost) YAML taking precedence.
Returns a string with the YAML content of the merge.
Merge $string1 through $stringN, with the nth-most (rightmost) YAML taking precedence.
Hash::Merge::Simple
This code is almost entirely based on the current implementation of Hash::Merge::Simple:
Robert Krimen robertkrimen@gmail.com
robertkrimen@gmail.com
Andre Santos <andrefs@cpan.org>
This software is copyright (c) 2012 by Andre Santos.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install YAML::Merge::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm YAML::Merge::Simple
CPAN shell
perl -MCPAN -e shell install YAML::Merge::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.