in reply to flock with anonymous filehandle

Your problem is the extra {}s around the filehandle. Although print lets you do that, since it uses a syntax not involving a comma, flock and seek do not. So change like:

flock({$nick},LOCK_EX);
to
flock($nick,LOCK_EX);

The syntax you had there created a hashref with nothing in it.

You really should be checking the return value of flock, and open.

(was updated because I really should've checked what { 'whatever' } produced.)