UNIVERSAL::can't

Ovid on 2007-12-19T16:34:44

We have a new module in our repository. Here's the complete source code (minus the docs):

package UNIVERSAL::can;
1;

This is due to the following bug:

$ perl  -MUNIVERSAL::can -w -e 'use Template::Timer'
Died at /home/poec01/branches/envscript/deps/perl5lib//Template/Timer.pm line 63.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

The offending line in Template::Timer which dies (with a less than helpful error message, though it's understandable why the author felt this would never really fail):

my $super = __PACKAGE__->can("SUPER::$sub") or die;

Sorry chromatic. I quite sympathize with the problem you're trying to solve and I agree that calling UNIVERSAL::can as a function is a bad thing which needs to stop, but globally altering behavior, even with the best of intentions, is simply too dangerous.


Fine By Me

chromatic on 2007-12-19T19:51:23

I don't blame you. In my copious free time I intend to overhaul UNIVERSAL::can similarly to UNIVERSAL::isa, such that it only does something if there's an actual, immediate bug present. Perl::Critic is a better way to find potential bugs here.

You might be able to reduce that to one line...

Alias on 2007-12-19T23:38:47

$INC{'UNIVERSAL/can.pm'} = 'No thanks';