in reply to yaml dynamically load in perl
Is it doable?
Yes, of course. How would you do it? Do you have some thoughts about how this might be done? Code?
I think that this tasks amounts to having config values treated as macros. A distinction between literal values, macros and referenced YAML keys has to be established. Macro values would be turned into an anonymous subs, so retrieving a value would be done like this (shown here with a hash):
my $val = ref $yaml{$key} eq 'CODE' ? $yaml{$key}->() : $yaml{$key};
or the like. You'd be inventing a macro language for your config files. The node tied hash for data munging is based on that. You should be very careful if you are going to shell out to get a value, since typos or mischief can be disastrous. Always run such code under -T (taint checks - see perlrun)!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: yaml dynamically load in perl
by louie_45 (Acolyte) on Nov 02, 2015 at 07:04 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2015 at 13:39 UTC | |
by louie_45 (Acolyte) on Nov 02, 2015 at 14:26 UTC |