I want (need) to run a subprocess from a perl script that checks for specific environment variables. In one case, the environment variable should be there, but empty.
$ENV{"GREETING"} = "Hello World";
$ENV{"GREETING"} = "";
I can set $ ENV {"GREETING"} = ""; and that the perl script $ ENV {"GREETING"} is empty, but this environment variable is not in any subprocess.
Here is a sample code to demonstrate. This script, env_in.pl sets some environment variables, ZZZ_3 is empty. Then it calls env_out.pl to output the environment variables, ZZZ_3 is absent.
use strict;`enter code here`
use warnings;
$ENV{ZZZ_1} = "One";
$ENV{ZZZ_2} = "Two";
$ENV{ZZZ_3} = "";
$ENV{ZZZ_4} = "Four";
my (@cmd) = ("perl", "env_out.pl");
system(@cmd) == 0 or die "system @cmd failed: $?";
Here is the env_out.pl script.
use strict;
use warnings;
print ($_," = ", $ENV{$_}, "\n") for (sort keys %ENV);
I am using ActiveState version v5.8.8 in a WinXP window.
I know this works in python, but I have no choice regarding the implementation language, it should be Perl.