in reply to Printing "log" output while debugging

You can also just "reopen" STDOUT to point it at the file:
$debug = 1; # toggle to 0 to turn off debug if ($debug) { open(STDOUT, ">/tmp/var/$0$$.log") or die "Unable to open $0$$.log + $!\n"; } print "If \$debug = 1 this will print to log otherwise print to the sc +reen(STDOUT)\n";