You might want to check out the
Mmap module on CPAN. It allows you to map a file into a Perl variable. As I understand it (and I've not used it) BSD & Linux allow a file to be mapped into memory. As you access various portions of the file, it basically page faults the corresponding block from the file into your user memory space. It seems that if you only access the front and end of a file, it will only load those parts, and not the remaining middle portion.
I don't know what the speed impact of using it would be, but it might be a possible way for manipulating your data.
I had thought this facility might be usable under Perl, so Thanks! to
chromatic for telling me where the module was.
--Chris