なるほど。
変えてみました。

open(FILE,"+<$filepath") or die(error);
flock(FILE,2);
@data=<FILE>;
#処理#
seek(FILE,0,0);
print FILE @data;
close(FILE);