alarthame has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting errors where I try to print the $data, and again where I try to change my incoming $value to be appended. Any point in the right direction, or words of wisdom would be appreciated.#! /usr/local/bin/perl -w use strict; use CGI qw(:standard); my $q=CGI->new(); open(FH,"+>>message.txt") || die("Cannot Open Data File.. Error"); seek(FH, 0,0); my $data = <FH>; print "Content-type:text/html\n\n"; print $q->start_html("My Message Board"); print "<h2>My Message Board</h2><br><hr>"; print $data; print "<p><hr><br>Post:<br>"; print "<center><form action=\"hw5.pl\" method=\"POST\">"; print $q->textarea(-rows=>6, -columns=>75, -name=>'text'); print "<br>"; print $q->submit(-value=>'Submit When Completed', -name=>'submit'); print "</form></center>"; print $q->end_html(); my $value=$q->param('text'); $value =~ s/\+/ /; $value =~ s/\r//g; $value =~ s/\n/ /g; print FH "$value"; close(FH);
Thanks,
alarthame
Update! I fixed that code a bit to reflect where I am right now. Thanks to Enlil for that little note that dealt it with the +>> I think that did it.
I'm still trying to get it so it won't tag on blank lines when I refresh the page. I've tried putting a line that stops the post if it's null, down by the $value, but that doesn't seem to work. Also, I'm not quite sure how to reset the textfield on a refresh. It like to repost the last entry or a blank field.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another Simple Message Board
by Enlil (Parson) on Nov 08, 2003 at 02:48 UTC | |
|
Re: Another Simple Message Board
by pg (Canon) on Nov 08, 2003 at 02:31 UTC | |
| |
|
Re: Another Simple Message Board
by sweetblood (Prior) on Nov 08, 2003 at 02:35 UTC | |
by alarthame (Novice) on Nov 08, 2003 at 02:45 UTC |