It sounds like you really want a semaphore rather than an environment variable. The behavior you see has nothing to do with perl and everything to do with the operating system. Either write to a file (rather than an environment variable) or use Win32::Semaphore or something