Gossamer Forum
Home : General : Perl Programming :

deleting & modifying text file entries

Quote Reply
deleting & modifying text file entries
Hi all,

I am using a random quiz script that has an admin section for adding questions. I would like to improve this by making it so I can also modify and/or delete questions (plus password protect it Wink ). Here is the code for adding:

Code:
print "Content-type: text/html\n\n";
$alt_answers .= $data{'alt_answer1'} if $data{'alt_answer1'};
$alt_answers .= "%%$data{'alt_answer2'}" if $data{'alt_answer2'};
$alt_answers .= "%%$data{'alt_answer3'}" if $data{'alt_answer3'};
$alt_answers .= "%%$data{'alt_answer4'}" if $data{'alt_answer4'};
open(FILE, ">>$questionfile") &#0124; &#0124; print "Could not open question file: $!<br>";
print FILE "$data{'question'}|$data{'answer'}|$alt_answers|\n";
close(FILE);

How do I identify the question(s) I would like to modify or delete? Is it by line number? Tips on how to write the new sections without messing everything up (I've already mastered that aspect, thanks anyway Smile ) would be greatly appreciated.

Thanks,
Dan