Zecho has asked for the wisdom of the Perl Monks concerning the following question:
This produces a comment likeThe CGI script: #!/usr/bin/perl -Tw use strict; use CGI; use CGI::Carp 'fatalsToBrowser'; use Fcntl ':flock'; use POSIX qw(strftime); my $now = strftime "%b %e", localtime; my $q = new CGI; my $user = length $q->param('user') ? $q->param('user') : "Anonymous"; $user = $q->escapeHTML($user); my $message = $q->param('comment'); if ($message){ # Avoid posting blank messages open FH, "+</var/www/html/comment.txt" or die "Oops: $!"; flock (FH,LOCK_EX) or die "Couldn't flock: $!"; my @comments = <FH>; seek (FH ,0,0); truncate (FH,0) or die "No can do: $!"; print FH "<br><b>On $now, $user added this bit o' wisdom:</b><br>$me +ssage<br><hr>\n"; print FH @comments; close FH; } print $q->redirect('http://server.com/index.shtml');
|
On Nov 17, Zecho added this bit o' wisdom: Here's my comment, yes it's a little boring, but it's a comment. |
Oh, and on a side note <coed> tags do not work. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Very simple commenting system
by Zaxo (Archbishop) on Nov 19, 2001 at 03:23 UTC | |
by blackmateria (Chaplain) on Nov 19, 2001 at 07:14 UTC |