in reply to writing to the top of a file

By asking to write to the top of a file you're implying that you want to insert bytes at the top while the rest of the file moves down.

Unrelated to Perl, filesystems typically don't provide functionality for that to happen transparently. What you need to do is read out the old file content into memory, insert the new data at the beginning (Perl's scalars or arrays are offering this in a nice transparent way) and then write the whole blob back to disk.