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


in reply to Format headers and filehandles

Add this:
select DM; $- = 0;
after your second open. I'm not intimately familiar with format and write, but this does the trick for me. Maybe someone more experienced could explain the magic, but this basically forces a new page on the next write.