I wish I had a Perl solution that I could point you to, but in the meantime you might try both
Peer Guardian and a firewall - if you don't have one already. I've had good success with
Sunbelt's Kerio firewall and the best thing is that both programs are free.
HTH!
Revolution. Today, 3 O'Clock. Meet behind the monkey bars.
I would love to change the world, but they won't give me the source code