Binary fileをupdateモードでopenして
目的の位置にseekしpackで元のファイルの内容を直接書き換える方法なら

ttps://docstore.mik.ua/orelly/perl/cookbook/ch08_14.htm