Toolkit review: Devel::Local, Devel::SimpleTrace, Reply
Nothing makes a lazy programmer happier than discovering free software that makes her or his job easier. Here are three of my favorites that I use on the daily:
Devel::SimpleTrace will add stack traces to 'die' and 'warn'. If you've ever seen library code that you don't recognize throw an error you don't understand this module should be in your toolkit.
#adapted/copied from the pod
$ perl -MDevel::SimpleTrace program_with_strange_errors.pl
or just put a 'use Devel::SimpleTrace' anywhere.
Basics of reading stacktraces:
- Skim from top to bottom.
- Stop when you see files that you wrote/recognize, and find the edge between files that are in your control and files that are out of your control.
- Work from there outwards until you identify the problem.
At SocialFlow.com we have a lot of internal perl distributions. We use Dist::Zilla to manage releasing our distributions to our internal (mini)CPAN, and we use Devel::Local to help us manage our PERL5LIB when developing multiple distributions at once.
$ source $( which devel-local.sh ) #in my ~/.bashrc
$ cd SF-Reporting-Schema/
$ devel-local .
#trimmed out some stuffs
#hack hack hack.....
$ cd ../SF-Web-Schema/
$ devel-local .
$ perl script/thing_that_relies_on_changes_in_reporting_schema.pl
Now both distros lib/ directories are in our perl path, and I can work on files in both spots. This allows us to keep our distributions separated yet work on them like they're all chucked into the same lib/.
Reply Reply is a great interactive perl shell ( REPL ). It's got some of extremely useful features that I had thought unique to ipython ( a really good python repl ):
- Tab completion
- ctrl-r history search
All together now
Devel::Local and Devel::SimpleTrace help you manage two of the most difficult/annoying parts of library development, pathing and debugging. Effectively dealing with these issues makes you a better developer. Reply is my scratchpad; letting me test out various ideas or try to remember how to get the last index of an arrayref member of a hashref. Without my tools, I'd be a slower, stupider person. It wasn't so long ago I was staring at a white screen trying to guess why www.mystupidwebsite.com/index.php wasn't working. I had no idea where the log file was; my only trick was to smack it until it works.