in reply to regex of hash key on the fly
If the files in question are of any significant size, sort the two files by the same key. Then, you can dispense with the use of a hash (and all of the virtual-memory it consumes) altogether.
Important: use a disk-based sort.
As "the COBOL-jockeys of yore" well-knew (and as the present ones still know), sorting a large file is an unexpectedly-fast operation. If you know that your inputs are sorted, then:
Although we might not routinely think of "main memory" as "a disk file," that is, in fact, what it is. A page-fault is expensive even if it does not result in physical I/O. If you are dealing with more than, say, a few thousand records, the amount of speed gained can be quite startling. (As in, hundreds of times faster.)
Also... don't let "tie" beguile you. A "tied hash" is not a hash. A convenient metaphor it may be, but a true hash it is not.