in reply to 'eq' matching not comprehensive

Use Devel::Peek to dump $header and $header_in_db in order to find out what those strings really are (encoding-wise, etc.)...

use Devel::Peek; Dump $header; Dump $header_in_db; if ($header eq $header_in_db) { ...

(look at "PV = ..." in the output)