Handy module: warnings::compat

schwern on 2007-07-02T21:48:31

If you're like me, and I hope you aren't, you have this strange compulsion to maintain compatibility with Perl 5.5. One of the most common problems backporting to 5.5 is it does not have "use warnings". You have to replace "use warnings" or "no warnings" with clunky things like "local $^W = 0". Annoying.

warnings::compat is a handy little module which installs a warnings.pm and warnings::register on older perls. It fakes up as much of the warnings interface as it can, including the functions. The major shortcoming is that it cannot be lexical and ignores warning groups (ie. "use warnings 'redefine'" just turns on warnings). For most uses of warnings this is fine and it does its job.

Since it will quietly install nothing on modern perls, its safe to include a dependency on warnings::compat in your CPAN module.