Gossamer Forum
Home : General : Perl Programming :

Splitting a file into multiple parts.

Quote Reply
Splitting a file into multiple parts.
I've written a program that builds .html pages from a database file that I specify. The database holds the majority of the record's information, but a seperate text file holds, what I'll call, the meat of record-- basically the body of the page that is built. I've realized that some of the text files are rather large and are too much for one HTML page (remember the 4 click rule). So, to solve this, I want to break the file up into digestable chunks. This is where the problem comes into play; I (a perl novice) have no idea how to break the file up into chunks that can be printed onto different pages.

It seems to me that the most logical way to do this would be to add a mark, of some kind, (ie. "<:NEXTPAGE:>") to the text file that would tell the program "This is the end of page one and the beggining of page two."

For example, a text file contains this text:

Bob and Joe went to the local pub for a drink.

<:NEXTPAGE:>

When they returned home, they found that their house had been robbed.

<:NEXTPAGE:>

etc....

The program creates 3 files:

Page 1. (bobandjoe,1.html)
Bob and Joe went to the local pub for a drink.

Page 2. (bobandjoe,2.html)
When they returned home, they found that their house had been robbed.

Page 3. (bobandjoe,3.html)
etc...

If someone could help me with this I'd be greatly obliged. Thanks for your time.

--Cade Ekblad-Frank





[This message has been edited by Cade (edited July 20, 1999).]