Gossamer Forum
Home : General : Perl Programming :

deleting

Quote Reply
deleting
In connection to my previous post I have a problem deleting names from my flat file database

I have a read standard input code

sub read_input {
my( $input, @pairs, $pair, $name, $value );

if ($ENV{'REQUEST_METHOD'} eq "GET") {
$input = $ENV{'QUERY_STRING'};
$get = 1;
}
elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
$post = 1;
}
else {
#* Offline mode goes here.
}

@pairs = split(/&/, $input);

foreach $pair (@pairs) {

($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/[^0-9a-z\/\-_: ]//gi;
$name =~ s/[^0-9a-z ]//gi;

$FORM{$name} = $value;
}
}
and then a delete code

sub EditFile_DeleteUser {
my( $old_list, $new_list, $user_no, $sorted_user );
$old_list .= $comments;
$new_list .= $comments;
foreach $user_no (@keys) {
$sorted_user = "$user_no\::$entrys{$user_no}\n";
$old_list .= $sorted_user;
$new_list .= $sorted_user;
$new_list =~ s/$FORM{DeleteRef}//gi;
$new_list =~ s/^\n//m;
}
open(INFILE, ">>$path$pwd") || die &error_file;
truncate INFILE, 0;
print INFILE $new_list;
close(INFILE);
}

the thing is that the code is working but in my input there is a section where the user has to enter their Japanese input and so i had to take away

$value =~ s/[^0-9a-z\/\-_: ]//gi;
$name =~ s/[^0-9a-z ]//gi;
from the first part of the code but when I did it, the delete code does not work anymore

does anyone know whats wrong?
Quote Reply
Re: [wired_lain] deleting In reply to
toss out your form parser and use the CGI module...

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy thoughts] deleting In reply to
I changed the code to

use CGI;
my $q = new CGI;
my %FORM = $q->Vars;

also edited

$new_list =~ s/\Q$FORM{DeleteRef}//gi;

in the delete section
but it still doesnt run, weird thing is, initially I entered the data straight through the flat file and if I try to erase those data it deletes fine, but when I try through the cgi it doesnt work anymore.

I tried to check the userlist tnad format and stuff is no problem, when I save it as is, its ok to delete it now

how come this happens?Unsure

Last edited by:

wired_lain: Nov 28, 2002, 1:11 AM