The environment variables of the shell are available through the %ENV hash in Perl. See perlvar for it.
The easiest way to make the variables available to a Perl script is to set them up beforehand:
#!/bin/bash . ~/.bash_profile /path/to/your/perlscript.pl
If that is not possible, you can follow the approach outlined in Get default login environment to get the environment variables that the script sets up. Specifically, RE (tilly) 3: Get default login environment has a subroutine that does what you want.
In reply to Re: source a file in Linux using perl script
by Corion
in thread source a file in Linux using perl script
by perl_007
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |