When I'm writing a program, I usually pepper it with debug print statements. After the program is working, I keep them in - they come in very useful if I ever need to fix a bug or add more functionality. I'm not at all worried about execution speed. Is there any better way of doing this?
my $debug = 1;
...
if ($debug>=1) { print "DEBUG: \$variable = $variable\n" }