in reply to setenv in perl

I'm not sure if I understand you correctly, but if you are trying to set the environment of the parent process calling your Perl script, then that's not possible.

The environment is always copied from parent to child process and not shared.

A changed environment in your Perl script is only visible inside this script and children processes of that script.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

update

If your problem is in the other direction, try export with variables meant to be available to a child process

lanx@ubuntu:~$ export TEST=TRUE lanx@ubuntu:~$ perl -E 'say $ENV{TEST}' TRUE

Replies are listed 'Best First'.
Re^2: setenv in perl
by Anonymous Monk on Jul 09, 2018 at 13:59 UTC
    Can you qx/export .../?
      you can but it doesn't make sense, since %ENV is by definition automatically exported.

      lanx@ubuntu:~$ perl -E '$ENV{TEST}=TRUE; say `echo \$TEST` ' TRUE

      Again, you can only effect the child process.

      ( update: please note you have three different processes in this example: ~$ Bash > Perl -E '...' > `Bash` )

      If you want to effect the parent process, you need to return text information which is either eval'ed or source'd (when put into a file).

      lanx@ubuntu:~$ eval `perl -E 'say q{export TEST=TRUE}'` lanx@ubuntu:~$ echo $TEST TRUE

      In other words the parent process always keeps full control of the environment.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice