in reply to Re: setenv in perl
in thread setenv in perl

Can you qx/export .../?

Replies are listed 'Best First'.
Re^3: setenv in perl
by LanX (Saint) on Jul 09, 2018 at 16:00 UTC
    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