in reply to Re: Writing to DATA
in thread Writing to DATA

In my experience, at least on some platforms, truncate right after print may fail. You need an intermediate seek to be safe.
print SELF new_crc($file),$/; seek SELF, 0, 1; truncate(SELF, tell SELF);
See also perldoc -f seek:
Due to the rules and rigors of ANSI C, on some systems you have to do a seek whenever you switch between reading and writing.

Perhaps you don't need the truncate — or the seek. CRCs tend to all be the same string length.