http://www.perlmonks.org?node_id=1004442


in reply to Global Variables Not Updated in Child Process

You seem to have a problem understanding the concept behind fork(). fork creates an exact copy of the current process, assigns it a new process ID, and makes both processes run independantly. Some things are shared, like file handles, but most (like memory) are not. (Actually, modern operating systems initially share most memory of both processes and use a copy-on-write mechanism to avoid expensive copy operations as long as possible.)

What you expect here is that your child will also have a hangover after only you got drunk.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)