Are there other ways for debugging Perl programs apart from Data::Dumper and perl -d?
During development, I like to embed printf statements in strategic places (not too many) which are enabled with a debug flag like this:
printf("h='$h', j='$j', ... (%d)\n", __LINE__) if $debug;
where the debug flag is defined at the top of the script:
my $debug = $ENV{DEBUG} || 0;
Now instead of having to remember to comment out all of the printf lines, I just run the script as follows:
DEBUG=1 ./script.pl
After testing when everything is ready for production, the debug lines can be removed:
cat script.pl | grep -v 'if $debug;'