CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Printing to html

 



btcmai
Deleted

Nov 1, 2000, 8:29 AM

Post #1 of 3 (322 views)
Printing to html Can't Post

In the current setup this subroutine will at present add new text before the first line at the top of a html file designated as $list. I want the information as its parsed from a form to be added to the last line of the html file as new information is added to the file.
Heres the script;
open (LISTFILE,"<$list") | | &noLIST;
@LINES=<LISTFILE>;
close(LISTFILE);
$SIZE=@LINES;
open (LISTFILE,">$list") | | die "Can't Open $output: $!\n";
$fileSIZE = $SIZE;

for ($i=0;$i<=$fileSIZE;$i++) {
$_="$LINES[$i]"."\n";
print LISTFILE $LINES[$i];

I'm sure there's an easy way to have the script write to the html file in the way I want it to. Can anyone out there assist me please. Thanks in advance


sleuth
Enthusiast / Moderator

Nov 1, 2000, 3:02 PM

Post #2 of 3 (322 views)
Re: Printing to html [In reply to] Can't Post

   <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
I want the information as its parsed from a form to be added to the last line of the html file as new information is added to the file.
<HR></BLOCKQUOTE>

huh? Isn't the new information comming from the form?

To append to a file just do this.

open (LISTFILE,">$list") | | die "Can't Open $output: $!\n";
print LISTFILE "$form{'stuff'}";
close(LISTFILE);

It's also not needed to loop through an array to print all the lines to a file, you can do this to add to the top of the file "$list"

open(file, "<$list") | | die "I'm Dead";
@orig=<file>;
close(file);
open(file_new, ">$list") | | die "I'm Dead";
print file_new "$form{'data'}\n";
print file_new @orig;
close(file_new);

Did I happen to answer your question? Because I really don't get what you need to do.

Slueth

[This message has been edited by sleuth (edited 11-01-2000).]


btcmai
Deleted

Nov 1, 2000, 3:21 PM

Post #3 of 3 (322 views)
Re: Printing to html [In reply to] Can't Post

yep thanks Slueth
After coming back and reading it myself again it was'nt that clear to me either but
you seem to got the general gist of what I was trying to explain.
btcmai

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives