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: Beginner:
Deleting an item from a list

 



srehal
Deleted

Mar 31, 2000, 7:17 AM

Post #1 of 2 (902 views)
Deleting an item from a list Can't Post

I have a list of documents on a page and I want the user to input the number associated with a particular document in a text field and then press the delete button.This should call a cgi script which should display to the user a new list minus the deleted document.
I have this code so far:
$NumberToDelete=$FORM{"numbertext"};

#opens a file to read
#checks to see if the number entered is the same as a number in the .csv file
#if it is then we want to delete it

#open(READONLY,"<document.csv");
# if ($NumberToDelete==Number) {
# print ("$Number,$Description,$Author,$Date,$Document\n");
# }
# print("You have entered a number that does not belong to an existing

#document");

open(READONLY,"<document.csv");
if ($NumberToDelete==Number) {
open(NEWFILE, ">>../NewDocument.csv");
print "$Number,$Description,$Author,$Date,$Document\n";
}
print("You have entered a number that does not belong to an existing

document");

close(NEWFILE);
close (READONLY);


Cure
User

Mar 31, 2000, 3:47 PM

Post #2 of 2 (902 views)
Re: Deleting an item from a list [In reply to] Can't Post

Hi

This will delete a user in your database.

$NumberToDelete=$FORM{"numbertext"};

open(READONLY,"document.csv");
open(NEWFILE, ">newdocument.csv");

while (<READONLY> ) {

my ($Number,$Description,$Author,$Date,$Document)=split/,/,$_;

print 'you have been succedfully deleted from our database' if($NumberToDelete==$Number);


if(!($NumberToDelete==$Number)) {

push @cure,$_;
}
}

print NEWFILE @cure;

close(NEWFILE);
close (READONLY);


Cure

 
 


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

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