in reply to Re^2: file lock error
in thread file lock error

From the documentation to which I linked,

import them from the Fcntl module, either individually, or as a group using the ':flock' tag.

Add

use Fcntl qw( :flock );

as in the example