getting env variables into perl scripts

Bill Campbell linux-sxs
Sat May 12 10:33:39 PDT 2007


On Sat, May 12, 2007, Net Llama! wrote:
>I've got this perl script that I inherited.  This perl script gets
>called from inside a bash script which has set an environment variable
>globally.  My problem is that the perl script isn't seemingly aware of
>the environment variable even though its definitely set globally
>inside the bash script.  Is there some way to force use of this
>environment variable inside the perl script?  I should note that the
>value of this variable changes over time, so I can't just hardcode it
>inside the perl script.

If it isn't in perl's $ENV hash, it's not in the environment.

Is something ``unset'ing'' it before running the perl script or perhaps in
some perl module that's being ``use'd'' or ``required''?

I would add a line immediately after the spitshell at the top of
the perl script to see if it's present at invocation.

	printf STDERR '>%s<\n', $ENV{'VARNAME'};

The >%s< is to make it easy to see an empty variable.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

The is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him.  -- Robert Heinlein



More information about the Linux-users mailing list