in reply to Need help! Data in file getting deleted

I hope I can explain this right.

I wish you could have, but... You seem to focus on the condition that causes this error message:

Duplicate Section Name: (some_parameter_string) Delete from UNIX command line.

Go To the Miscellaneous link and click the 'Remove whitelist lock'

and you seem to think this has something to do with file locking. But there is nothing in the code provided that has anything to do with file locking. Your "seive_until_remove_filter" sub has an array called "@lock" and a variable called $filelock, but these appear to contain FTP host names, because your code goes like this:

sub seive_until_remove_filter { my ($relay, $relay_dir, $filename, $home_dir, @lock) = @_; ... foreach my $filelock ( @lock ) { ... if ( my $ftp = Net::FTP->new($filelock)) { ... ## delete some "flag" file(s) from some path } else { sieve_util_generic_error ("Unable to login to $relay."); } ...

Could it be you're just using the wrong variable as the ftp host to connect to? What file is it that's getting truncated -- one that is specifically opened in the code shown, or some other file whose name is passed around in one of the parameter strings?

Maybe you'd better start from first principles. What is this app supposed to do? What conditions are in place when it begins, what user input/decisions are required to make it work, and how are conditions different when it's done? What are the specific boundary conditions or exceptions that will alter its behavior and results? Which of those is causing the trouble?

Try running it from the command line with "perl -d" to step through the conditional block and/or sub that is supposed to handle the problem case, and check whether the relevant variables have the values you expect, whether the conditionals are evaluating the way you intend, etc. If you've been "looking at this code for a few days" without using the debugger to step through it, you're wasting your time.