Well, after seen all the solutions proposed, the truth is that I would go for the simplest one:
Just copy AnyEvent/DNS.pm from the AnyEvent distribution somewhere under your source tree (for instance, under a directory called patched_modules), make the required modifications there and then ensure it is in the module search path before the original:
BEGIN { unshift @INC, './patched_modules' }
use AnyEvent;
use AnyEvent::DNS;
I would also add a version check into my modified version of AnyEvent::DNS:
AnyEvent::VERSION eq "7.17" or
warn "New version of AnyEvent ($AnyEvent::VERSION) detected, please
+upgrade ".__FILE__." accordingly";