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.