Another one where I post a partial answer to my own question. The problem seems to be that I have made an assumption about how filehandles behave. The code for Copy will open and close the file if given a filename but not if given a filehandle. This makes sense. What surprised me was that closing the file would release the lock. I was thinking that if I had obtained the lock by using filehandle XX then I would have to close it through XX to release the lock. I didn't do an explicit close and was expecting the lock to exist until the end of the script
Copy says "Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible." - which is how I got into this mess in the first place