in reply to Creating a file with Open
Everyone has already said to include $! in the error
message. This is important but it is only a start.
You should also do as perlstyle says and include $user_name.
And personally I would begin sweating at trusting user input for filenames. Have you verified that the name looks like what you think it should? See perlsec for more on that issue.
And btw that code for flocking will not give you the protection you want, open it "+<$user_name" or else it gets wiped out before you try to lock it.
In Section
Seekers of Perl Wisdom