I read in a lot of places that "autodie" is something that can be used in the same fashion as "use strict" or "use warnings" to catch problems. I started putting it into a lot of places and automatically adding to the top of every script. However, for something which is intended to go into every Perl script, this module is very slow to load:
****** Item 1:
print "hello world.\n";
$ time perl noautodie.pl
****** Item 2:
print "hello world.\n";
$ time perl autodie.pl
I don't use this module any more, because of this performance problem.
(Someone wrote to me who was worried that I thought that autodie affected the time of "print" above. In case anyone is confused, please note that "autodie" doesn't affect the time of "print", as far as I know. You can remove the "print" and still get the same sort of time results. Check the autodie documentation at the link above the review for what the module does.)
I started using autodie in almost all of my applications a few months ago. It's somewhat of a mixed blessing. For existing applications, it can break things and making things less robust, solely because old code are not built with autodie in mind.
But the best thing about it is that it's lexically scoped, so for sections of code that you're not sure about, just sprinkle 'no autodie' to get the old behaviour.
It should be used on probably 95% of code out there. For the rest of the cases, where you need to report the status of each I/O operation, it's obviously more convenient to check $? instead of trapping exception everytime.
A great extension of Fatal.pm. For private stuff I use it very frequently. I wish it would be part of the core modules.
At work all our redhat machines use cpan2rpm'ized packages. Unfortunately autodie overwrites Fatal.pm instead of making a fork, so I can't install it because it conflicts with the system perl. A patch rt.cpan.org/Ticket/Display.html?id=49608 is underway.
I use this pragma in almost all of the applications, like so:
use autodie qw( :all );
I wish that the behavior enforced by autodie were the default in Perl. With autodie, I do not have to think about testing every little open() and system(). Yes, you can test every $! and $?. But what if once in a while you forget to test? Or what if you inherit someone else's code? Are you sure all the tests are in place there? Regardless of that, such tests clutter the code and detract from the main purpose of the code.
Note that for system(), backticks (``) and exec() to work with autodie,
IPC::System::Simple module must be installed!