in reply to How to test for open file handles?

jdrago 999:

Perhaps it would be better to "mock" the filehandle by commandeering the open & close methods. Then open could increment a variable, and close could decrement it. At the end of your test, the variable should be zero. I'm sure there's a way to intercept the core functions, but I don't know how to do it, so I can't offer any assistance on the actual implementation.

...roboticus

Replies are listed 'Best First'.
Re^2: How to test for open file handles?
by jdrago_999 (Hermit) on Feb 04, 2009 at 01:40 UTC
    Perhaps it would be better to "mock" the filehandle by commandeering the open & close methods.

    I'm currently using IO::File. I could subclass it, do some singleton whiz-bang stuff and keep track of opens vs closes there.

    I just figured there might be a special Perl variable that would tell me how many files had been opened - something I could check for changes over time.