Well, there's no magic way to do this. You basically have the perl script open the "data file" and read it's contents. As you read each line, you print out the resulting line of HTML code. When you are done, you have a full HTML page, either printed out to the screen (sent back to the user) or printed to a flat file (for viewing on your site).
That's the basic overview of one way to do it, anyway. Hope it helps.