in reply to running sh script from perl script

This is what is happening:

If you need to have a second process alter the memory or environment of another process, you need to look into programming with threads or shared memory. Your other alternative would be inter-process communication.