in reply to Why is my program so slow even though I've used hashes?

Well, programs don't run faster magically just because you use hashes. They only give you speed if you don't have to loop over the whole hash, but look up the values by key.

So instead of using your current keys for storage, use the value that is called $pdbchain in your program as a hash key. Then you can replace whole while (($key, $value) = each %hash) { if ($a eq $b) { ... } } with a single hash lookup, which should improve the performance.