I tried with the following code,
$res = get_login_env();
print $res;
sub get_login_env {
local %ENV;
my $env = `echo env | perl -e 'exec {"C:\\temp\\test.bat"} -sh'`;
print $env;
if (wantarray) {
my @pieces = ($env =~ m/^(.*?)=((?:
|\\.|\\\n)*)/gm );
s/\\(.)/$1/g foreach @pieces;
return @pieces;
}
else
{
return $env;
}
}
Where the test.bat file is having the set commands.
It is not throwing error and it is not getting the varible also.