i'm using the external text file mod but don't want the file to be mandatory. if someone has entered text that has been written to the external file, but later deletes the text when modifying the record, i cannot get the program to delete the external file. i tried using the code in the sub delete part of the mod in the modify part of db.cgi:
if ($in{'text'}) {
open (TEXT, ">$save_text_dir/$in{$db_key}.txt") or &cgierr("error in modify_record. unable to open text file $save_text_dir/$in{$db_key}.txt\nReason: $!");
print TEXT $in{'text'};
close TEXT;
}
else {
unlink "$save_text_dir/$data[$db_key_pos].txt";
}
i thought if there was no $in{'text'} because the existing text was erased, that this unlink command would delete the related file, but it doesn't work. can someone pls point me in the right direction? thanks.
Code:
if ($in{'text'}) {
open (TEXT, ">$save_text_dir/$in{$db_key}.txt") or &cgierr("error in modify_record. unable to open text file $save_text_dir/$in{$db_key}.txt\nReason: $!");
print TEXT $in{'text'};
close TEXT;
}
else {
unlink "$save_text_dir/$data[$db_key_pos].txt";
}
i thought if there was no $in{'text'} because the existing text was erased, that this unlink command would delete the related file, but it doesn't work. can someone pls point me in the right direction? thanks.