Re: setting several environment variables in the current shell process
[email protected] ("Danny R. Faught") Mon, 20 Sep 2004 15:09:01 -0500
| Newsgroups | perl.trainers |
|---|---|
| Organization | Tejas Software Consulting |
| Message-ID | <[email protected]> |
Gaurav Arora wrote: > In csh based scripts, I can use the 'source' keyword, or in 'sh' based > scripts, I can use the '.' symbol. But what would be the equivalent in > Perl ? To simplify things, you can use the shell's "eval" command. Then you won't need to save the variables in a file. For example: ................... $ cat env-var #!/usr/bin/perl print "export FOO='my value'\n"; $ ./env-var export FOO='my value' $ eval `./env-var` $ echo $FOO my value ................... Note that this assumes that you're not using a shell that uses csh syntax - to be portable, you'd need to have the Perl script accept an option to specify which of the two common syntaxes to use for setting variables. -- Danny R. Faught Tejas Software Consulting http://tejasconsulting.com/