in reply to Re: Retrieving evironment variables from a shell script
in thread Retrieving evironment variables from a shell script
How about this, which is also shorter and simpler:
my $rcfile = 'testrc'; # exports environment vars %CFG = split /\0/, `. $rcfile; $^X -e 'print join("\\0", %ENV)'`;
(Special var $^X is the patch to the perl binary. And the double backslash is important.)
If there's any possibility that the config file might do some printing to stdout, you have to get a little more paranoid. Otherwise, this should be fine.
-- Chip Salzenberg, Free-Floating Agent of Chaos
|
|---|