If I did understood you well you remove the file from the command line while it is locked by the Perl script - and you are supprised that you can do that. It depends on the system you are using, but on some (if not on most of them) the flock call is a C library call - and thus it is just a advisory lock, not a mandatory one. So with shell you can allways go around it.
Then that "another Perl program" first needs to check whether the file is locked or not, and unlink() or truncate() (if appropriate) it only if it's not locked.