Your excessive use of RAM seems only because you need to process all the files before writing the first line of output. I'd be more inclined to create an empty file and open it in readwrite mode (+< not >>), write the old 10 hexits of the first file just as a placeholder, process each file, skipping subsequent headers and when finished sysseek back to the beginning, overwrite with the new 10 hexits and close up. But you have to limit the functions on the readwrite filehandle to sysseek and syswrite, e.g. (write a load of As, rewind and overwrite 10 Bs at the beginning):
use strict;
use warnings;
use Fcntl 'SEEK_SET';
system "touch myfile";
open my $fh, '+<', 'myfile';
syswrite $fh, 'A' x 100000, 100000;
sysseek $fh, 0, SEEK_SET;
syswrite $fh, 'B' x 10, 10, 0;
close $fh;
(updated)