Cool.
I had previously convinced myself that because BEGIN requires a block, I couldn't fake out 'use warnings' for people who don't have it but then I realized this works fine:
BEGIN {
if( eval { require warnings } ) {
warnings->import();
} else {
$^W= 1;
}
}
because the pragmas already expect to be inside of a (invisible) block and so apply themselves to one block further out.
I like this method because it allows the user to install a back-ported warnings.pm or bytes.pm or whatever and use it if they want to and I don't have to trust my knowledge of when the module was added. (:
Anyway, it is another way to do it.
- tye |