In shell, I had sourced .cshrc
file which contains some defined variables like user name.
I need to pass these variables to a certain Perl script.
For example in shell terminal, I typed
>echo $user
The output is >esaad
Then in Perl, to read $user
variable, I tried:
system("echo $user")
Also tried this command:
my $userName = system(
echo $ENV{user}
);
but Perl asked for $user
initialization as Perl variable not Shell one.
How I could read this variable?
You can:
the reason your system call doesn't work is that system open a new shell that doesn't source .cshrc read this answer for more information