in reply to Help adding a worksheet in a subroutine with Spreadsheet::WriteExcel

You may have said that you posted too early and that calling close() is the answer to your problem, but it is indeed a mistery documented in the entry for close() in Spreadsheet::WriteExcel.

In addition, close() may be required to prevent perl's garbage collector from disposing of the Workbook, Worksheet and Format objects in the wrong order. Situations where this can occur are:

This is basically a bug, I think. The implementation probably use weak references or something similar which allows objects to be disposed without a discipline needed for correctly handling composite objects. The invoking of close() is the documented workaround.