Consider the below code:
#!/usr/bin/perl
use strict;
use warnings;
$value="export PI = 3.14";
open(IN,">>/root/.bashrc");
print IN $value;
close(IN);
`source /root/.bashrc`;
I want to create an env variable using a Perl script. I've given 777 permissions to the root folder as well as the .bashrc file. The $value in the script is getting appended to .bashrc but when i use "env " or "printenv" to display env variables, i cant see the one which is appended to .bashrc.I guess the source command is not working, because when i source the .bashrc file from CL its showing in the env list.Please help me out or suggest another way.Thanks in advance.