Take a look at
IO::Zlib. I believe it'll do exactly what you want -- that is, tie a compressed file and treat it like an ordinary file handle (a la
Tie::File). In your case, I wouldn't keep the large data record compressed AND use a compressed data file -- I don't see that it buys you anything. Just use
IO::Zlib and compress the whole file.
--RT