[comp.lang.perl] How to export Environment variables from a perl script to the shell?

jmc@eagle.inesc.pt (Miguel Casteleiro) (04/14/91)

Hi there!

I need to set some environment variables in a Perl script,
and, at the end of the script, I need them to be exported to
the running shell (tcsh).  So, how can I do that?

Thanks for any info!!
--
 Miguel Casteleiro at INESC, Lisboa, Portugal.  (jmc@eagle.inesc.pt)  _ //
 "News: so many articles, so little time..."                          \X/

tchrist@convex.COM (Tom Christiansen) (04/14/91)

From the keyboard of jmc@eagle.inesc.pt (Miguel Casteleiro):
:I need to set some environment variables in a Perl script,
:and, at the end of the script, I need them to be exported to
:the running shell (tcsh).  So, how can I do that?

You need to write them to stdout and eval the output.

% eval `cmd`

where cmd is a perl script that outputs something like:

    setenv foo bar;  setenv alpha omega; 

etc.

--tom