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:
modify and delete options in a discussion forum

 



maaritkn
Deleted

May 16, 2000, 3:27 AM

Post #1 of 4 (518 views)
modify and delete options in a discussion forum Can't Post

As a school project I'm making a discussion forum for Flash with Perl through telnet. It enables you to add a message, and/or modify or delete any of the messages (I'm not supposed to care about security). Messages are stored in another file and that part is working. In addition to storing the text that the user has typed, an id-number is added into that file (before the text the user has typed).
Now I don't know how to make these modify and delete options. It should be done with the help of the ID-number but I don't know what to do! Could somebody help me, tell how to proceed??????????
My page is at cgi.evitech.fi/~maaritkn/project3.cgi


nagao
Deleted

May 16, 2000, 2:07 PM

Post #2 of 4 (518 views)
Re: modify and delete options in a discussion forum [In reply to] Can't Post

is each of the replies in a different file or does your data file look like this

123
Lalalalal

124
blalkjd;lkj


maaritkn
Deleted

May 18, 2000, 4:14 AM

Post #3 of 4 (518 views)
Re: modify and delete options in a discussion forum [In reply to] Can't Post

At least for the time being all the messages are saved in one data file. It looks like this:
1234%name%topic%version%message
2344%name%topic%version%message

So how should I proceed?


nagao
Deleted

May 18, 2000, 11:37 AM

Post #4 of 4 (518 views)
Re: modify and delete options in a discussion forum [In reply to] Can't Post

For delete:

open (FILE, "$file);
while (<FILE> )
{
$line = $_;
@fields = split(/\%/,$line);
unles ($fields[0] == $delete_number)
{
$page = "$page\n$line";
}
}
close (FILE);
open (FILE,">$file")
print FILE $page;
close (FILE);

For modify, do similar thing except if the number == modify number then replace the fields with a new line like this

$new_line = "$id\%$new_name\%$new_topic\%$new_version\%$new_message";

$page = "$page\n$new_line";

I think you'll get my meaning

Nick

 
 


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

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