http://qs321.pair.com?node_id=308273

marynella has asked for the wisdom of the Perl Monks concerning the following question:

I have an existing problem with Perl/OLE, that I'd like you to take a look at. In my script there is a call to:
Win32::OLE->new( 'InternetExplorer.Application', sub {$_[0]->Quit;} )
It appears that the behavior of Win32::OLE->new is as follows:
  1. If there is an existing instance of InternetExplorer(IE) running, then it will return a handle to the existing IE application.
  2. If there is not an existing instance of IE running, then it will create a new instance of IE, and return a handle to this new instance.
I seem to be having a concurrency/race condition problem with this call, when multiple scripts get the same instance of IE for the handle. Can you help me to find a way to change this call, so that it ALWAYS returns a new instance of IE and does not try to look for an already existing instance of IE?

Note: I am currently using Win32::Mutex to avoid the concurrency/race condition problems. However, this is not the best solution.
Thanks!

update (broquaint): tidied up formatting