This opens the document and stores the data in a variable:
@data = <data>;
you then call the each line of the document through the variable like this:
$data[linenumber] or @data for everything in the document.
to add a line to the bottom of the text do the following:
print data "info here";
where >> adds a new line and > clears the document and then adds the line
hope it helps