engtech has asked for the wisdom of the Perl Monks concerning the following question:
sub CheckForMsgs { my $strMsg = ''; my @MsgArray = (); my $MsgDate = 0; my $Message = ''; my $GuestName = ''; my $id = 0; my $colorflag = 0; my $bgcolor = "#FFFFCC"; # open the file for read open(DAT,"Guestbook.cgi") || die("Cannot Open File:$!"); @MsgArray = <DAT>; close(DAT); foreach $id (@MsgArray) { chomp ($id); ($id,$MsgDate,$GuestName,$Message)=split (/\|/,$id); # alternate table row background color to contrast entries. if ($id%2 eq 1){ $bgcolor = "#FFFFCC"; $strMsg .= "\ <tr bgcolor=\"$bgcolor\"><td> $MsgDate < +/td><td align=center> $GuestName </td><td> $Message </td></tr> \n"; } else { $bgcolor = "#DFDF00"; $strMsg .= "\ <tr bgcolor=\"$bgcolor\"><td> $MsgDate < +/td><td align=center> $GuestName </td><td> $Message </td></tr> \n"; } } return $strMsg; }; ####End of Sub sub WriteNewMsg { my @MsgArray = (); my $id = 0; my $NewMsg = ''; my $GuestName = ''; my $now_string = strftime "%a %b%e %H:%M %Y", localtime; my $NewID = 1; &ReadParse(*input); # open the file for read open(DAT,"Guestbook.cgi") || die("Cannot Open File:$!"); @MsgArray = <DAT>; close(DAT); open(DAT,">>Guestbook.cgi") || die("Cannot Open File:$!"); foreach $id (@MsgArray) { chomp ($id); ($id,$MsgDate,$GuestName,$NewMsg)=split (/\|/,$id); ++$NewID; } # add Event to file print DAT "$NewID|$now_string|$input{'txtGuestName'}|$input{'txtMs +g'}\n"; close(DAT); }; ###End of Sub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple guestbook problem.
by Happy-the-monk (Canon) on Jul 01, 2004 at 21:08 UTC | |
|
Re: Simple guestbook problem.
by muba (Priest) on Jul 01, 2004 at 21:05 UTC | |
|
Re: Simple guestbook problem.
by beable (Friar) on Jul 01, 2004 at 23:11 UTC | |
|
Re: Simple guestbook problem.
by nightwatch (Scribe) on Jul 01, 2004 at 23:21 UTC |