@BKB
I'm curious - do you distinguish at all between Perl.com - O'Reilly's site for selling Perl related books and conferences, and the Perl community?
And, it is possible to write a Perl script to check that one's web page hasn't been hijacked. Of course their page hadn't been hijacked - it was a trusted third party.
To anticipate your next statement, I'm not sure that it is, in general, possible to prevent scenarios like this. Advertisement brokers tend to require that a site link the scripts etc. directly from the broker's server, essentially bypassing the content provider.
This is done so the broker can update the scripts whenever they need to, and can help protect against content providers gaming the system.
However, once they are out of the loop, content providers have little ability to control what is displayed.
This problem has happened once in approximately 10 years, and yes, it is embarrassing for O'Reilly Media, but I can't really see what could be done within the current model of advertisement serving.