The semantics of UNIVERSAL::can() are quite sensible, but in some ways
the bare coderef it returns is inconvenient since using it exposes the
internals of Perl's method call syntax. Here's an alternative:
{ package UNIVERSAL;
sub closure {
my $pkg = shift;
my $sub = can($pkg, shift);
$sub && sub { $sub->($pkg, @_) };
}
}
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Wow, this theory not only proves that Bill Gates is evil, but it proves
that our basic number system is flawed. THAT'S AMAZING!"
-- Passenger Pigeon in alt.religion.kibology