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

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

My Perl script is doing some preliminary manipulation of data in an Excel spreadsheet and then opens it up for the user to make additions/changes. I want to detect when the user has finished and then proceed with additional processing. My first attempt was the following:
print "When finished editing, close the file.\n"; sleep 3; $excel->{Visible} = 1; while ($excel->ActiveWorkbook) { sleep 10; }
This works only under certain timing-dependent conditions. It works if the user closes the file without making any changes. It also works if changes are made only during the sleep period. However if a cell is being edited when the ActiveWorkbook object is being tested, a message appears which says "The message filter indicated that the application is busy", the test fails, and the while loop is terminated. The same thing happens if one tries to close the file and the ActiveWorkbook object is tested while Excel is waiting for a response to "do you want to save changes?".

Is there a way to test if the "message filter" (whatever that is) is busy? Is there some other way to detect when the user has finished editing and has closed the file?