Don't ask to ask, just ask | |
PerlMonks |
"require Carp" may be hazardous to your codeby Steve_p (Priest) |
on Dec 05, 2006 at 15:51 UTC ( [id://587888]=perlmeditation: print w/replies, xml ) | Need Help?? |
I've been testing a lot of modules with bleadperl and have run into a few issues with some modules, but for the most part modules have installed just fine. There have been one rather common issue with some CPAN authors' use of Carp. In normal code, it will probably look like this.
Here's a one-liner with Perl 5.8.8 and bleadperl that demonstrates the problem.
What's the difference? The code above is relying on some undefined behavior of warnings.pm. warnings used Carp which would invade the namespaces of other modules that used warnings. With change #23768, warnings was changed to only require Carp when it is needed. Without some module using Carp and importing it into the global namespace, it turns into another bareword, unless you put parentheses around your arguments.
How common is this problem? Common enough, I guess. I’ve so far tested around 800 CPAN distributions with bleadperl, and have seen around ten modules fail with this problem. That’s just over 1% of the modules. This figure may go up or down, since it seems to correlate to the CPAN author, rather than something happening at random. If an author uses the require Carp idiom incorrectly once, it seems pretty likely that they’ll do it again. This may hit non-CPAN code a bit harder since error handling routines are typically copy-and-pasted around or placed in a common module. If done incorrectly, it could bring down an application, or a whole suite of applications. So, please, please, please, test your modules with bleadperl! Its better to do it now rather than wait for Perl 5.10 to be released. See my signature for details on how to get a bleadperl and test with it. Steve_p Test your modules with bleadperl! rsync -avz rsync://public.activestate.com/perl-current/ . ./Configure -des -Dusedevel -Dprefix=/path/to/test/perl make test make install Now, please test you modules! If you have test failures that don't happen with Perl 5.8.8, send a simplified test case to perlbug at perl.org
Back to
Meditations
|
|