Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Set environment variable for one time system command windows

by aitap (Deacon)
on Mar 27, 2013 at 19:41 UTC ( #1025798=note: print w/ replies, xml ) Need Help??


in reply to Set environment variable for one time system command windows

Since running a command requires a separate process, fork it and set the environment variable via %ENV, then exec your program:

if (fork == 0) { local $ENV{myvariable} = "test"; exec("echo ".($^O eq "MSWin32" ? "%myvariable%" : '$myvariable')) or +die "exec: $!\n"; } __END__ text
Sorry if my advice was wrong.


Comment on Re: Set environment variable for one time system command windows
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2015-07-28 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls