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:
because the pragmas already expect to be inside of a (invisible) block and so apply themselves to one block further out.BEGIN { if( eval { require warnings } ) { warnings->import(); } else { $^W= 1; } }
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.
- tyeIn reply to Re^2: use bytes without breaking perl 5.005 or 5.004? (also)
by tye
in thread use bytes without breaking perl 5.005 or 5.004?
by joshclark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |