in reply to Tracking Lines Printed to a FileHandle
If you can't count the lines before calling print, it should be feasible to create a tied handle class that counts them as they are printed.