mmhh, interesting, there are two ways to fix that:
rename your lock routine
move the declaration of the lock-sub above the other subs
it seems to me that there is a clash with the lock funtion (perldoc -f lock) from thread programming but I'm not sure on that. Can someone enlighten me??