Thursday, September 17, 2009

how to do pythonic perl 3: To carp and croak is better

Use carp and croak instead of warn and die.
The primary reason is that the carp module produces more useful information, especially when used inside modules. That is, the user is more interested in where the offending code was called from instead of where your module crapped out.

Find the Carp module here on CPAN.

Thanks to chorny for pointing out useful resources that led me to the Carp module.
It was the Perl::Critic module that led me to this particular bit and I will be doing more tips from the Perl Best Practices book by Daman Conway

No comments: