Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: format Header only prints on first of several files

by broomduster (Priest)
on Sep 06, 2008 at 16:40 UTC ( [id://709524]=note: print w/replies, xml ) Need Help??


in reply to format Header only prints on first of several files

I use format/write quite a bit, but never exactly this way... ;-)

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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://709524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found