It might be easier to help if you give us some idea of what the code is like (not /necessarily/ the code itself.)
Does the current program already break the formatted data into pages, or does that come from printing it out? Depending on what the formatted data looks like, whether a long entry can be broken up across a couple pages or not, etc you could use some variable to count the number of lines printed out and do the headers & footers every X lines. Of course if you want "page X of Total" rather than just "page X" you'll need to know the total length of the file; so you may want to just add in a second loop after the one you already have, which inserts the headers and footers where appropriate. I don't know of any particular CPAN module for that but I'm far from the most knowledgeable on this list ;) ~wren