Gossamer Forum
Home : General : Perl Programming :

deletes a phrase

Quote Reply
deletes a phrase
Hi
I made this script for deleting lines from an ascii file.
I found that it doesn't delete a phrase (composed by 2 or more words)

For example if i try to delete (via form) the word: "White" with no other phrase containing "White" in the database it works correctly
When type something like
-----
White House
White Tie
White
------
I can't delete them.

source:
---------
sub deletecategory {
open(FILE,"$catfile") | | die "could not open catfile";
@cat = (<FILE> );
close(FILE);
$count_lines=0;
foreach $line (@cat) {
$count_lines++;
chomp $line;


if ($line eq $FORM{'category'}) {
$line = '';
}


if ($line ne '') {
$line = "$line\n";
push(@contents, $line);
}
}
open(FILE,">$catfile") | | die "could not open catfile";
print FILE @contents;
close(FILE);
print <<htm;
<HEAD><meta http-equiv="refresh" content="0; url=$ENV{'HTTP_REFERER'}"></HEAD>
htm
}


[This message has been edited by wizard (edited February 19, 2000).]
Quote Reply
Re: deletes a phrase In reply to
To complete the previous message.
I noticed that the query_string contains something which could create the problem. I'M SURE IT IS CREATING THE PROBLEM

See: "....&category=NewCartegory%0D%0A"

I would need to remove %0D%0A and the script works. The problem is .... how?
Quote Reply
Re: deletes a phrase In reply to
Have you tried the following codes:

Code:
my ($key);
foreach $key (keys %in) {
if ($in{$key} =~ /\%0D\%0A/) {
$in{$key} =~ s/\%0D\%0A//g;
}
}

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums