in reply to A simple but good debug routine..

Useful, but with one slight modification,

sub debug { print STDERR shift if ($debug); }

it might turn out even more useful in the long run.

This prints the debug text to Standard Error, which means that if you pipe the output of your script to a file or command, you will still see the warnings, but they won't appear in the final file.

Cheerio!
Osfameron