This is likely to be considerably slower than the in-memory hash version. If memory suffices I'd be inclined to do the same thing with Bit::Vector, perhaps via my ancient wrapper, Tie::IntegerArray.
-sam
Comment on Re^2: A better (problem-specific) perl hash?