} elsif ( $remtag == "1" ) {
$remove_email = $formdata{rem_name};
open(FILE, "$filename");
while (<FILE>) {
@fields = split(/\@/, $_);
if ( $fields[0] ne $remove_email ) {
open(NEWFILE, ">>$tmpfile");
print NEWFILE "$_";
close(NEWFILE)
}
}
close(FILE);
}
i am taking a value from a form, say "info".
i open my file for reading. the file has the format
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]
...
i read the file in a while loop and split each line based on the @ symbol.
if the form value "info" does not match the first field of the split array
item, then i open a temp file and write the entire line to this temp file.
this works a little too well :)
the file loops through a couple times causing multiples of lines from
$filename to be written to $tmpfile. can someone point out my error?
sorry for so many questions. its my first day with perl.
thanks for everyone's help! -charles