in reply to Re: read file into scalar
in thread read file into scalar

Everything you need except for locking, which this OP seems to need. Though if a lock isn't needed for the whole read/update data/write cycle, File::Slurp's atomic option may be enough.