Look, it's canon that Doof's musical theme is four guys that he hires to sing it. Clearly, Perry's musical sting also exists in-world, and Doof can hear it. When a platypus crashes into your lab and you hear a James Bond-esque musical riff and girls singing, "Per-RY...!!", you don't have to be an evil pharmacist to figure it out.
Although, Doofenschmirtz can be a little thick sometimes.
Although, Doofenschmirtz can be a little thick sometimes.