> -----Original Message-----
> From: perl newbie [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 6:22 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: setting and importing ENV from within PERL
>
>
> I am trying to figure out if there is a way to :
>
> a) set an ENV variable from within a perl script and
> then print out it's value from within the same shell.
>
> Here is the code that I am trying to use:
>
> #!/usr/bin/perl -w
> use strict;
>
> # set some environment variables.
> system(`setenv MY_VAR "test"`);
Problems here:
1) the backticks are asking perl to run the setenv command, and then
substitue the stdout of that command (probably nothing) and send it to
system(). You need to lose the backticks.
2) setenv is a csh built-in, and backticks use /bin/sh (see perldoc perlop).
Hence, the error message you're getting.
3) system() runs commands in a subshell. Any changes to the environment made
in the subshell will not affect the environment of your perl script.
The solution is just to assign %ENV:
$ENV{MY_VAR} = "test";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]