in reply to conditional debug call perf
You might want to take a look at Log::Log4Perl. I can't say it's going to reduce your performance overhead, but it will make your logging (for debugging and other purposes) more flexible.
Have you profiled or benchmarked your code to see if those "if" statements are really causing any performance issues? Usually you'll find those bottlenecks elsewhere, such as in file I/O or database calls.
Here's an article on Log4Perl you might find useful: Retire your debugger....
In Section
Seekers of Perl Wisdom