in reply to Strange flock results?

It may be an issue with the current file location being at the wrong place, in which case seeking to the end will help. This example is from Perl's documentation for flock:
sub lock { flock(MBOX,LOCK_EX); # and, in case someone appended # while we were waiting... seek(MBOX, 0, 2); }
You could also try opening the file in append mode, which instructs the OS to take care of this for you. If you want to truncate the file immediately after opening it, you can use truncate:
open (BADADDR, ">>badmails.csv") || die; truncate (BADADDR,0) || die; open (GOODADDR, ">>goodmails.csv") || die; truncate (GOODADDR,0) || die;