Question : Control object destruction during global destruction

Hi all

I have around 100 test scripts, this scripts have a global variable that represent a database connection. Since I'm needing to have a DB cleaning, when I exit the scripts, I was using the destructor of my object to do the work. The problem is that at the end, the order of destruction isn't controlled, all goes. So when I try to clean the database the connection is already down some times.


Note: I don't wont to go inside the scripts and discover where DB is no longer needed, and doing a clean close of the DB. I need something +- generic


As a generic solution I'm considering to set all the code of this scripts inside a block, and this would control the object destruction.

Someone has a simpler solution? For instance a insert of some code filter coming out of CPAN for instance ...

Answer : Control object destruction during global destruction

My understanding is that you should be able to put your DB cleanup code inside an END block in order to have it run before anything else is done about cleanup.

If you are already using END (not sure if that's what you mean by destructor or not), let me know and I'll see what else I can figure out.

An END block is simply:

END { ...code... }
Random Solutions  
 
programming4us programming4us