Definitely print / printf!
A couple of tricks I've used over the years, both in C and Perl:
- Put something in the print statement to indicate it's temporary. I use 'TFD' ('Temporary For Debugging'), which is easy for me to search for after I'm through debugging, to take out all of the lines containing it:
print "TFD> About to call &parse_results ...\n";
&parse_results($p);
printf "TFD> Done &parse_results, p->[0] = '%s'\n", $p->[0];
-
Put reverse-video escape sequences around text to really make it stand out. "<ESC>[7m" will turn ON reverse-video for ansi-capable terminal windows (eg. *nix), and "<ESC>[m" will turn if OFF (this will especially be helpful when you're generating tons of output, as the eyes can quickly spot reverse-video text):
if ($mystr =~ /Total lines processed:\s+(\d+)/) {
my $total = $1;
return $total;
}
print "TFD> \e[7mUnexpected format of 'mystr':\e[m\n";
print "TFD> '$mystr'\n";