Sorry, jafuser, I couln't resist rewriting your code as a perl one liner:

perl -ne 'chop;$w{reverse $_}=$_;print "$_\t$w{$_}\n" if $w{$_}'