The reason that the header info is only included in the first file is most likely a consequence that your total lines of all index files are less than the value of $= (current page length - see perlvar), which defaults to 60. If not, then find the file with the 58th line (59th, something like that ;)) and you should find a header.

Top-of-Page Formats are meant for hardcopy devices, but you can achieve the results you want with a simple hack: make $= equal to the number of lines you are about to print plus 2 for the numbers of lines in INDEXFILE_TOP. Here is an example:

use strict; my ($prog,$desc,$pages,$date,$file); my @line1 = ( qq|prog desc pages data file\n|, qq|foo blah 5 bar foo.txt\n|, qq|bar blah 5 baz bar.txt\n|, qq|baz blah 5 qux baz.txt\n|, ); my @line2 = ( qq|prog desc pages data file\n|, qq|foo blah 5 bar foo.txt\n|, ); $~ = 'INDEXFILE'; write_2_file(@line1); write_2_file(@line2); sub write_2_file { $= = 2 + @_; for (@_) { chomp; ($prog,$desc,$pages,$date,$file) = split; write; # to STDOUT for this example } } format INDEXFILE_TOP = Program Description Pages Date Filename ------------------------------------------------ . format INDEXFILE = @<<<<< @<<<<<<<<<<<<<<<<<< @<<<<< @<<<<< @<<<<<<<<<<< $prog, $desc, $pages, $date, $file .
The only things that really bugs me about this code is having to hard code the number of lines in INDEXFILE_TOP. There might be a way to derive this number, i'll be on the lookout for it (anybody knows...feel free to share ;))

UPDATE: Doh! Looks like rinceWind has a much cleaner answer.

Change '$= = 2 + @_' to '$- = 0' in the above example for a more robust subroutine. rinceWind++

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Format Question by jeffa
in thread Format Question by nimdokk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.