libuniversal-can-perl

safer version of UNIVERSAL::can

Description

The UNIVERSAL class provides a few default methods so that all objects can use them. Object orientation allows programmers to override these methods in subclasses to provide more specific and appropriate behavior.

Some authors call methods in the UNIVERSAL class on potential invocants as functions, bypassing any possible overriding. This is wrong and one should not do it. Unfortunately, not everyone heeds this warning and their bad code can break good code.

This module replaces UNIVERSAL::can() with a method that checks to see if the first argument is a valid invocant (whether an object -- a blessed referent -- or the name of a class). If so, and if the invocant's class has its own can() method, it calls that as a method. Otherwise, everything works as you might expect.

If someone attempts to call UNIVERSAL::can() as a function, this module will emit a lexical warning (see perllexwarn) to that effect. You can disable it with no warnings; or no warnings 'UNIVERSAL::isa';, but don't do that; fix the code instead.

Upload more screenshots

Please help extend the collection of screenshots. Just make a screenshot and upload it here. You don't need to register or anything.

Upload a screenshot

Hint: upload an image here from your clipboard with Ctrl-V


Homepage

https://metacpan.org/release/UNIVERSAL-can


Install this software package

If the package is available for the distribution you are currently using on your computer then install the software by clicking on…

Install libuniversal-can-perl