in reply to format Header only prints on first of several files
write effectively keeps a running tally of the number of lines printed on the current page. (To be more precise, $- holds the number of lines remaining on the current page.) Apparently, $- is not getting reset when you close RF and then open it again. You should put
$- = 0;
right after close RF;. And in order to get that to work, you need to select your filehandle so that $- is associated with RF.
Here's a sample:
use strict; use warnings; format RF = testing . format RF_TOP = top_of_form . for ( 1 .. 3 ) { open (RF, ">testfile$_") or die "Can't open file testfile$_: $!"; select(RF); write RF; write RF; close RF; $- = 0; }
|
|---|