make each of the pair of strings an array
step through first array, each position you find a underscore, put the underscore in the second array in same position.
now step through second array, and in each position you find a underscore, put one at the same position in first array.
join each array into a scalar and compare both scalars with string comparison operator (eq)
the initial traversing of both arrays can be easily done in one loop. i just wrote it the (2 loop) way to more clearly illustrate.
the hardest line to type correctly is: stty erase ^H