Subject: | Warning is too universal |
The docs say...
Also, if you pass the "−always_warn" flag on the import line, this
module will warn about all incorrect uses of "UNIVERSAL::can()".
This
can help you change your code to be correct.
It fails to mention that it will warn if warnings are turned on
regardless of the state of the -always_warn flag, although that is
implied by earlier documentation.
IMHO the UNIVERSAL::can warning is too universal. If any component of a
system uses it the entire code base is infected, including code which is
out of my direct control (for example, CPAN modules). While it is
useful to have that and bug CPAN authors to fix their code, the
"all-or-nothing" behavior of UNIVERSAL::can means that upon hitting a
UNIVERSAL::can warning in CPAN code my options are...
* Live with it until the CPAN author fixes their code
* Turn off all warnings.
* Locally patch the CPAN module to fix the code.
* Locally patch the CPAN module to shut up the warning.
* Remove the loading of UNIVERSAL::can.
None of these are particularly desirable.
The problem is that an issue in one module (for example, Class::DBI) is
being spread out across all (probably unknowing) users of UNIVERSAL::can.
What's missing is a way to globally shut up UNIVERSAL::can so it doesn't
bug the entire community about one person's problem. Or just not have
it warn by default and you have to turn it on. I would suggest the
warning be controlled by an environment variable and default to off. It
can be turned on by setting the environment variable, setting -always_on
or "use warnings 'UNIVERSAL::can'".