ianwinter has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm trying to setup a YAML file using YAML::XS, now, for the most part it's fine if I use a standard YAML format, but, I'd like to include defaults and aliases, but, whenever I load a "defaulted" block it's in a << hash first.
#!/usr/bin/env perl use Data::Dumper; use YAML::XS; my $config = LoadFile('config.yml')->{'production'}; print Dumper($config);
defaults: &defaults src: host: localhost database: db username: root password: nfs: /tmp development: <<: *defaults test: <<: *defaults production: <<: *defaults nfs: ian
I'd also ideally like to be able to override the defaults. If my block looks like this:
production: src: host: localhost database: db username: root password: nfs: /tmp
All is well and fine. Any tips gratefully received, the alias stuff comes from a ruby background.

Replies are listed 'Best First'.
Re: YAML Alias (xml)
by Anonymous Monk on Apr 21, 2015 at 23:17 UTC