in reply to Question about a perl script

That perl one-liner is fine but it is only a little part of what you want to do. You will either need to feed those IPs into iptables and drop their traffic or configure your web browser to stop those IPs accessing or maybe just posting to your forum.

Did you see http://www.reaper-x.com/2012/05/15/how-to-block-tor-on-apache-and-nginx/ ?