The everywhere trick
I also pepper
use Data::Dump; dd $something; in my code a lot! So many that I created DD and DDC to lessen the typing. But this trick is better because I don't have to put the use statement at all. Plus I get some safety (I do accidentally check in these debugging print statements from time to time).
-MData::Dump::Color on the command-line or PERL5OPT will only work for the code in the
main package. What if I pepper debugging statements in some module? That's where another nice module written by Brock Wilcox comes in: everywhere. This module lets you use a module, well, everywhere. It works by installing a coderef at the start of
@INC that will trap every require statement and import the modules you want to import everywhere to the target module. By the way, this @INC handler trick is also employed by some other cool modules, among others: App::FatPacker and PAR.
So now you can just put "dd" statements in your modules and test your application with:
perl -Meverywhere=Data::Dump yourapp.pl
or some shorter alias which I'm sure you'll soon create if you use this often enough.