quietgecko has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way in which environment variables are recognized by YAML files
use YAML; my ($hashref) = Load(<<'...'); --- Home: "$ENV{HOME}" ... print Dump ($hashref);
The above snippet results in:
Hence the environment variable is not interpolated.HOME: '$ENV{HOME}'
UPDATE:
Thanks Everyone for your replies. Greatly appreciate it.
As MidLifeXis pointed out, I was only providing a self contained example.
In reality I have the YAML as a separate file that will have a lot of entries.
But as afoken and RonW pointed out, It looks like interpolation is not supported and we may need to do data manipulation
Here is a snippet that mimics my actual case
use YAML; my ($hashref) = YAML::LoadFile("test.yaml"); print Dump ($hashref); print $h;
The content of the test.yaml:
Home: "$ENV{HOME}"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Environment Variables in YAML
by NetWallah (Canon) on Nov 17, 2015 at 05:58 UTC | |
by MidLifeXis (Monsignor) on Nov 17, 2015 at 14:05 UTC | |
by NetWallah (Canon) on Nov 17, 2015 at 16:42 UTC | |
by quietgecko (Initiate) on Nov 18, 2015 at 05:36 UTC | |
by NetWallah (Canon) on Nov 18, 2015 at 21:46 UTC | |
|
Re: Environment Variables in YAML
by afoken (Chancellor) on Nov 17, 2015 at 05:10 UTC | |
|
Re: Environment Variables in YAML
by RonW (Parson) on Nov 17, 2015 at 18:02 UTC | |
|
Re: Environment Variables in YAML
by MidLifeXis (Monsignor) on Nov 18, 2015 at 14:39 UTC |