Gossamer Forum
Home : General : Perl Programming :

Printing to a certain area

Quote Reply
Printing to a certain area
How do you print text or anything to a certain are of a file? Like if I wanted to print the word "dog" between two images:
<img src="http://dog.gif">
<img src="http://dog1.gif">
How would I put it between them like

<img src="http://dog.gif">
dog
<img src="http://dog1.gif">

Also how do you print to the top of a file instead of appending to the bottom? Like if I wanted a guestbook to add the entry to the top of the guestbook.

------------------
Patrick Chukwura
Nytesoft WebSolutions
nytesoft.hypermart.net
Quote Reply
Re: Printing to a certain area In reply to
Question #1) Use <BR> for each new line you want. Example:
Code:
<img src="http://dog.gif"><BR>
dog<BR>
<img src="http://dog.gif">

Question #2) Try this...
You have to open the file, store the contents in memory, write the new message, then write the contents back to the file and close the file.

Code:
open (NEW, ">$path_to_file");
print NEW $newmessage;
print $newmessage;
for ($i = 1; $i >= 0; $i++) {
print NEW "$lines[$i]";
print "$lines[$i]";
}
print NEW "\n";
close(NEW);

Hope this helps,
Chris

------------------
webmaster@racedaze.com

[This message has been edited by ChrisE (edited May 24, 1999).]

[This message has been edited by ChrisE (edited May 24, 1999).]